473,511 Members | 10,041 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel VBA Listbox

risk32
98 New Member
Hello.
I am having a problem with Excel VB. I'm trying to use the value of items in a listbox to manipulate a caption to a label. Any suggestions? I haven't tried to use index, and frankly I don't know how.

Here's what' I've started with:
With lbDay1
.AddItem "01"
.AddItem "02"
.AddItem "03"
.AddItem "04"
.AddItem "05"
.AddItem "06"
.AddItem "07"
.AddItem "08"
.AddItem "09"
.AddItem "10"
.AddItem "11"
.AddItem "12"
.AddItem "13"
.AddItem "14"
.AddItem "15"
End With
........
Private Sub lbDay1_Click()
lbDay1.Value = lblLink2.Caption
End Sub
Aug 21 '08 #1
2 3085
MikeTheBike
639 Recognized Expert Contributor
Hello.
I am having a problem with Excel VB. I'm trying to use the value of items in a listbox to manipulate a caption to a label. Any suggestions? I haven't tried to use index, and frankly I don't know how.

Here's what' I've started with:
With lbDay1
.AddItem "01"
.AddItem "02"
.AddItem "03"
.AddItem "04"
.AddItem "05"
.AddItem "06"
.AddItem "07"
.AddItem "08"
.AddItem "09"
.AddItem "10"
.AddItem "11"
.AddItem "12"
.AddItem "13"
.AddItem "14"
.AddItem "15"
End With
........
Private Sub lbDay1_Click()
lbDay1.Value = lblLink2.Caption
End Sub
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Private Sub UserForm_Initialize()
  4.     With lbDay1
  5.         .AddItem "01"
  6.         .AddItem "02"
  7.         .AddItem "03"
  8.         .AddItem "04"
  9.         .AddItem "05"
  10.         .AddItem "06"
  11.         .AddItem "07"
  12.         .AddItem "08"
  13.         .AddItem "09"
  14.         .AddItem "10"
  15.         .AddItem "11"
  16.         .AddItem "12"
  17.         .AddItem "13"
  18.         .AddItem "14"
  19.         .AddItem "15"
  20. End With
  21.  
  22. End Sub
  23.  
  24. Private Sub lbDay1_Click()
  25.     lblLink2.Caption = lbDay1
  26. End Sub
  27.  
??

MTB
Aug 21 '08 #2
risk32
98 New Member
More coding might be of some help... Do you know how to add pictures to this?

Private Sub cmdBack_Click()
MultiPage1.Value = 0
End Sub

Private Sub cmdNext_Click()
MultiPage1.Value = 1
End Sub

Private Sub cmdGenerate_Click()
MultiPage1.Value = 2
lblLink = "\\yofs13\374OG\36AS\Asgard_data\data\Duty Desk\Electronic Boards Info\Schedule Slides\2008\"
End Sub

Private Sub Form_Load()
lblAirfield.SetFocus
End Sub

Private Sub txtYear_click()
txtYear.MaxLength = 2
If txtYear = "" Then
MsgBox "Please enter a year"
txtYear.SetFocus
End Sub

Private Sub cmdGo_Click()
Shell ("C:\Program Files\Microsoft Office\OFFICE12\POWERPNT.EXE " & Chr(34) & lblLink.Caption & Chr(34))
End Sub

Private Sub lbDay1_Click()
lbDay1.Value = lblLink2.Caption
End Sub

Private Sub optAirfield_Click()
If optAirfield.Value = True Then
MultiPage1.Value = 2
End If
lblLink = "\\yofs13\374OG\36AS\Asgard_data\data\Duty Desk\Electronic Boards Info\Schedule Slides\2008\INFO & STATUS\Info And Status.ppt"
lblLink = lblLink.Caption
End Sub

Private Sub optSched_Click()
If optSched.Value = True Then
MultiPage1.Value = 1
With lbDay1
.AddItem "01"
.AddItem "02"
.AddItem "03"
.AddItem "04"
.AddItem "05"
.AddItem "06"
.AddItem "07"
.AddItem "08"
.AddItem "09"
.AddItem "10"
.AddItem "11"
.AddItem "12"
.AddItem "13"
.AddItem "14"
.AddItem "15"
End With
With lbDay2
.AddItem "16"
.AddItem "17"
.AddItem "18"
.AddItem "19"
.AddItem "20"
.AddItem "21"
.AddItem "22"
.AddItem "23"
.AddItem "24"
.AddItem "25"
.AddItem "26"
.AddItem "27"
.AddItem "28"
.AddItem "29"
.AddItem "30"
.AddItem "31"
End With
With lbMonth
.AddItem "January"
.AddItem "February"
.AddItem "March"
.AddItem "April"
.AddItem "May"
.AddItem "June"
.AddItem "July"
.AddItem "August"
.AddItem "September"
.AddItem "October"
.AddItem "November"
.AddItem "December"
End With
End If

End Sub
Aug 25 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
8489
by: Jean | last post by:
Hello, I have a form that performs a search, according to criteria that a user enters into the text boxes. When the user clicks on „Search", a SQL string (say strSQL) is built up with the...
3
8911
by: Conrad F | last post by:
Hello All, I know how to import a specific named excel sheet into a datagrid using ADO.NET by setting up a JET connection and then SELECTing data from the sheet. However, for a real world...
3
8878
by: George | last post by:
Sub ExcelToListBox() Dim xRange As Object Dim ary Dim xValue As String xRange = oXL.Range("A1:A9") 'has letters A-H ary = xRange.value xValue = ary(3, 1) 'xValue = C...
0
1102
by: Piotr Kosinski | last post by:
Hi, I noticed strange behaviour in Excel. I wrote small shared add in for Excel. This util create button in standard bar. Button click provides to open a form which has to import data from sql...
18
8268
by: Frank M. Walter | last post by:
Hello, I have made an small AddIn with udf for excel 2003. I use vs2003. The point of view is the function __T() I call it in excel sheet writing =__T() I am not able to set a value to a...
1
5716
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
1
2777
by: bbasberg | last post by:
Hello, I am wondering how to "carry over" a value from a listbox on one worksheet in the workbook to a cell in another worksheet in the same workbook. For example, to just copy over a value...
2
1788
by: dan NY | last post by:
I'm a struggling new VB Applications user that has what may be a simple question, but I've been struggling with it. I'm using a response to a message box YesNo question to cause one of two...
18
4582
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
5
6370
by: GeorgeBro | last post by:
I am having a problem trying to select items from a listbox that is drawn on my worksheet. I have no problem adding items, or removing items.... only when I try to identify the items that are...
0
7367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7089
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7517
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5673
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5072
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1581
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
451
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.