problem in Combo Box

ram_Sathish

New Member
Joined
Jun 12, 2006
Messages
15
Hi all,

I have two fields one is text box and the other one is a combo box. The text box is called total no.of pages and the combo box is called page no.

The moment i enter a number in the text box then it should be created that many rows in a combo box.

Let me explain through an example. When i entered the number 50 in the text box then the combo box should capture / show me like

Page 1 of 50
Page 2 of 50
.
.
.
Page 50 of 50

Similarly if i enter a number say 45 it has to show

Page 1 of 45
Page 2 of 45
.
.
.
Page 45 of 45


I think do loop or for statment will help me. Am i Correct?

Anyone please help me.


Thanks in advance.


Regards,


Ramsathish S
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Hi

Try using something like this in the after update event of the text box that contains the number of pages :

Code:
Private Sub MyTextBox_AfterUpdate()

Dim TotCount As Integer, LoopCount As Integer

TotCount = Nz(Me.MyTextBox.Value)

If TotCount = 0 Then
    MyComboBox.Enabled = False
Else
    MyComboBox.Enabled = True
    MyComboBox.RowSource = ""
    MyComboBox.RowSourceType = "Value List"
    For LoopCount = 1 To TotCount
        MyComboBox.AddItem LoopCount & " of " & TotCount
    Next LoopCount
End If

End Sub

Make sure you use your actual text box and combo box names where I have used MyTextBox and MyComboBox.

You will need to add error checking to pick up if the user has entered non-numerical characters into the text box.

HTH, Andrew
 
Upvote 0

Forum statistics

Threads
1,214,973
Messages
6,122,534
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top