Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Qn: SpinButton1.Max not working??
Hello to ALL Experts,
I have designed a UserForm that should display Doctors in different Counties where I live. I have 4 different sheets for 4 different counties that contain all the information. I have a ComboBox1 to select the different counties. I also have a spin button that cycles through all the doctors. I have about 10 doctors in County Marion, about 5 doctors in County Hendricks, and I have about 3 or 4 in the other two. My UserForm1 code is below. What the problem is, the userform comes up fine, and I have it default to Marion County. But, it displays 1 of 1 doctors when there is 10 in Marion. Now, if I click the spin button, then it cycles through to 2 of 10, 3 of 10 and so on. But, if I click on Hendricks County or any other county, it will only show the first Doctor and 1 of 1. I cannot display any other Doctors in any county, including if I return back to Marion. Then it is like the other counties, just the first record 1 of 1. Can somebody look at my code below and see what I have done wrong??? Sure would appreciate it. Thanks in advance... mv Option Explicit Dim County As String Dim HelpTopic As Integer Private Sub CancelButton_Click() Unload Me End Sub Private Sub UpdateForm() HelpTopic = SpinButton1.Value LabelAME.Caption = Sheets(County).Cells(HelpTopic, 1) LabelDoc.Caption = Sheets(County).Cells(HelpTopic, 2) LabelClass.Caption = Sheets(County).Cells(HelpTopic, 3) LabelPL.Caption = Sheets(County).Cells(HelpTopic, 4) LabelPhone.Caption = Sheets(County).Cells(HelpTopic, 5) LabelAdd.Caption = Sheets(County).Cells(HelpTopic, 6) LabelNote.Caption = Sheets(County).Cells(HelpTopic, 7) Me.Caption = "AME's in " & County & " County (Doctor " & HelpTopic & " of " & SpinButton1.Max & ")" End Sub Private Sub ComboBox1_Change() If ComboBox1 = "Marion County" Then County = "Marion" With SpinButton1 .Max = Application.WorksheetFunction.CountA(Sheets("Mario n").Range("A:A")) .Min = 1 .Value = 1 End With UpdateForm If ComboBox1 = "Hendricks County" Then County = "Hendricks" With SpinButton1 .Max = Application.WorksheetFunction.CountA(Sheets("Hendr icks").Range("A:A")) .Min = 1 .Value = 1 End With UpdateForm If ComboBox1 = "Hamilton County" Then County = "Hamilton" With SpinButton1 .Max = Application.WorksheetFunction.CountA(Sheets("Hamil ton").Range("A:A")) .Min = 1 .Value = 1 End With UpdateForm If ComboBox1 = "Hancock County" Then County = "Hancock" With SpinButton1 .Max = Application.WorksheetFunction.CountA(Sheets("Hanco ck").Range("A:A")) .Min = 1 .Value = 1 End With UpdateForm End Sub Private Sub SpinButton1_Change() HelpTopic = SpinButton1.Value UpdateForm End Sub Private Sub UserForm_Initialize() Me.Caption = APPNAME ComboBox1 = "Marion County" With SpinButton1 .Max = Application.WorksheetFunction.CountA(Sheets("Mario n").Range("A:A")) .Min = 1 .Value = 1 End With End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Calculate working days but change working week | Excel Discussion (Misc queries) | |||
Making weekend days working days - the system cuts the working tim | Excel Discussion (Misc queries) | |||
macro was working, now it's not working | Excel Programming | |||
Macro working in Excel 2003; not working in Excel 2000 | Excel Programming | |||
Adding sales from a non working day to the previous working day | Excel Programming |