Hi all. I'm pretty new to the VBA game. I've got a large spreadsheet with many cells that need user input. A bunch of calculations are performed on subsequent worksheets, but I want the user to only see the fields they need to enter. I'm trying to write some code that will use a scrollbar (form control, not activex) to only show one group of columns at a time. For example, if ScrollBar1.Value = 1, then show columns "A:D" and hide colums "E:Z". If ScrollBar1.Value = 2, show colums "E:H" but hide columns "A:D" and "I:Z", etc.
Here's the code I'm trying to get going, but I keep getting various errors when I try to execute.
As it stands now, when I click the scrollbar I get the error: "Compile error. Method or data member not found," and the ".Value" in Line 3 is highlighted. Is there something obvious that I'm doing wrong?
Thanks!
Here's the code I'm trying to get going, but I keep getting various errors when I try to execute.
Code:
Private Sub ScrollBar1_Change()
Dim v As Integer
v = ScrollBar1.Value
Columns("A:Z").Select
Columns("A:Z").EntireColumn.Hidden = True
Select Case v
Case 1
Columns("A:D").Select
Columns("A:D").EntireColumn.Hidden = False
Case 2
Columns("E:H").Select
Columns("E:H").EntireColumn.Hidden = False
Case 3
Columns("I:L").Select
Columns("I:L").EntireColumn.Hidden = False
End Select
End Sub
Private Sub ScrollBar1_Scroll()
ScrollBar1_Change
End Sub
As it stands now, when I click the scrollbar I get the error: "Compile error. Method or data member not found," and the ".Value" in Line 3 is highlighted. Is there something obvious that I'm doing wrong?
Thanks!