ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA code for Userform (https://www.excelbanter.com/excel-programming/283678-vba-code-userform.html)

Martin Los

VBA code for Userform
 
I want to create a Userform with Excel 97 that includes:
- 1 combobox cmdDay indicating Day (1-31)
- 1 combobox cmbMonth indicating Month (Ene-Dic) (=
Spanish format!)
- 1 checkbox indicating whether I should include a
directory
- 1 checkbox indicating whether I should include another
directory.
-1 textbox which should represent selection of combox
cmdDay
-1 textbox which should represent selection of combox
cmdMonth

Questions:

1) Can anybody provide sample code to get Combobox
cmbMonth filled with name of months?

Should be similar to:
With cmbDay
For i = 1 To 31
.AddItem (i)
Next
End With

2) What VBA code gets selection of combobox into the
textbox? (ie. textBox.Text = cmbMonth.Value?)

3) If I create Userform with names and then try executing
code, what means error "Variable not defined"?

Thanks in advance,

Martin


J.E. McGimpsey

VBA code for Userform
 
1) one way:

cmbMonth.List = Array("January","February",...,"December")

or

Dim i As Long
With cmbMonth
For i = 1 To 12
.AddItem Format(DateSerial(1, i, 1), "mmmm")
Next i
End With

2)
Private Sub cmbMonth_Change()
TextBox1.Text = cmbMonth.Value
End Sub

3) It means that you've set Option Explict, which requires that all
variables be declared in a Dim (or Static, Public, etc.) statement.



In article ,
"Martin Los" wrote:

I want to create a Userform with Excel 97 that includes:
- 1 combobox cmdDay indicating Day (1-31)
- 1 combobox cmbMonth indicating Month (Ene-Dic) (=
Spanish format!)
- 1 checkbox indicating whether I should include a
directory
- 1 checkbox indicating whether I should include another
directory.
-1 textbox which should represent selection of combox
cmdDay
-1 textbox which should represent selection of combox
cmdMonth

Questions:

1) Can anybody provide sample code to get Combobox
cmbMonth filled with name of months?

Should be similar to:
With cmbDay
For i = 1 To 31
.AddItem (i)
Next
End With

2) What VBA code gets selection of combobox into the
textbox? (ie. textBox.Text = cmbMonth.Value?)

3) If I create Userform with names and then try executing
code, what means error "Variable not defined"?

Thanks in advance,

Martin


No Name

VBA code for Userform
 
Dear J.E. McGimpsey

Thanks a 1.000.000 for your help..which has got me going
working again!

Yours sincerely

Martin Los

-----Original Message-----
1) one way:

cmbMonth.List = Array

("January","February",...,"December")

or

Dim i As Long
With cmbMonth
For i = 1 To 12
.AddItem Format(DateSerial(1, i, 1), "mmmm")
Next i
End With

2)
Private Sub cmbMonth_Change()
TextBox1.Text = cmbMonth.Value
End Sub

3) It means that you've set Option Explict, which

requires that all
variables be declared in a Dim (or Static, Public, etc.)

statement.



In article ,
"Martin Los" wrote:

I want to create a Userform with Excel 97 that includes:
- 1 combobox cmdDay indicating Day (1-31)
- 1 combobox cmbMonth indicating Month (Ene-Dic) (=
Spanish format!)
- 1 checkbox indicating whether I should include a
directory
- 1 checkbox indicating whether I should include

another
directory.
-1 textbox which should represent selection of combox
cmdDay
-1 textbox which should represent selection of combox
cmdMonth

Questions:

1) Can anybody provide sample code to get Combobox
cmbMonth filled with name of months?

Should be similar to:
With cmbDay
For i = 1 To 31
.AddItem (i)
Next
End With

2) What VBA code gets selection of combobox into the
textbox? (ie. textBox.Text = cmbMonth.Value?)

3) If I create Userform with names and then try

executing
code, what means error "Variable not defined"?

Thanks in advance,

Martin

.


Dana DeLouis[_3_]

VBA code for Userform
 
Don't know if this would work for you. An Array of month names
(January...December) comes built-in as Custom list #4 (U.S. English) Don't
know about foreign language though.

cmdDay.List() = [Row(1:31)]
cmdMonth.List() = Application.GetCustomListContents(4)

HTH.
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


wrote in message
...
Dear J.E. McGimpsey

Thanks a 1.000.000 for your help..which has got me going
working again!

Yours sincerely

Martin Los

-----Original Message-----
1) one way:

cmbMonth.List = Array

("January","February",...,"December")

or

Dim i As Long
With cmbMonth
For i = 1 To 12
.AddItem Format(DateSerial(1, i, 1), "mmmm")
Next i
End With

2)
Private Sub cmbMonth_Change()
TextBox1.Text = cmbMonth.Value
End Sub

3) It means that you've set Option Explict, which

requires that all
variables be declared in a Dim (or Static, Public, etc.)

statement.



In article ,
"Martin Los" wrote:

I want to create a Userform with Excel 97 that includes:
- 1 combobox cmdDay indicating Day (1-31)
- 1 combobox cmbMonth indicating Month (Ene-Dic) (=
Spanish format!)
- 1 checkbox indicating whether I should include a
directory
- 1 checkbox indicating whether I should include

another
directory.
-1 textbox which should represent selection of combox
cmdDay
-1 textbox which should represent selection of combox
cmdMonth

Questions:

1) Can anybody provide sample code to get Combobox
cmbMonth filled with name of months?

Should be similar to:
With cmbDay
For i = 1 To 31
.AddItem (i)
Next
End With

2) What VBA code gets selection of combobox into the
textbox? (ie. textBox.Text = cmbMonth.Value?)

3) If I create Userform with names and then try

executing
code, what means error "Variable not defined"?

Thanks in advance,

Martin

.




Colo

VBA code for Userform
 
Just for every body's information
An Array of month names
(January...December) comes built-in as Custom list #4 (U.S. English)

It's same in Japanese version as well.

--
With best regards,
Colo

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
Colo VBA guy! of 'The Road of The Cell Masters' :)

URL:http://www.interq.or.jp/sun/puremis/...astersLink.htm

/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/


"Dana DeLouis" wrote in message
...
Don't know if this would work for you. An Array of month names
(January...December) comes built-in as Custom list #4 (U.S. English)

Don't
know about foreign language though.

cmdDay.List() = [Row(1:31)]
cmdMonth.List() = Application.GetCustomListContents(4)

HTH.
--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


wrote in message
...
Dear J.E. McGimpsey

Thanks a 1.000.000 for your help..which has got me going
working again!

Yours sincerely

Martin Los

-----Original Message-----
1) one way:

cmbMonth.List = Array

("January","February",...,"December")

or

Dim i As Long
With cmbMonth
For i = 1 To 12
.AddItem Format(DateSerial(1, i, 1), "mmmm")
Next i
End With

2)
Private Sub cmbMonth_Change()
TextBox1.Text = cmbMonth.Value
End Sub

3) It means that you've set Option Explict, which

requires that all
variables be declared in a Dim (or Static, Public, etc.)

statement.



In article ,
"Martin Los" wrote:

I want to create a Userform with Excel 97 that includes:
- 1 combobox cmdDay indicating Day (1-31)
- 1 combobox cmbMonth indicating Month (Ene-Dic) (=
Spanish format!)
- 1 checkbox indicating whether I should include a
directory
- 1 checkbox indicating whether I should include

another
directory.
-1 textbox which should represent selection of combox
cmdDay
-1 textbox which should represent selection of combox
cmdMonth

Questions:

1) Can anybody provide sample code to get Combobox
cmbMonth filled with name of months?

Should be similar to:
With cmbDay
For i = 1 To 31
.AddItem (i)
Next
End With

2) What VBA code gets selection of combobox into the
textbox? (ie. textBox.Text = cmbMonth.Value?)

3) If I create Userform with names and then try

executing
code, what means error "Variable not defined"?

Thanks in advance,

Martin

.






All times are GMT +1. The time now is 02:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com