Hi mikerees,
Check the sheet named "sheet4" actually exists. The "subscript out of range" error is often indicative of erroneously named objects.
Cheers,
Wayne
Main Topics
Browse All TopicsHi there
The following code works brilliantly in the current sheet.
However, I need to divert out to another sheet to hide a number of columns, and then come back into the current sheet.
The line of code causing the problem is the 'Worksheets("sheet4)....'
Private Sub SpinButton1_Change()
Dim MYNUM As Integer
Dim MINROWNO As Integer
Dim MINCOLUMN As Integer
Dim COUNTER As Integer
Rows("25:49").Select
Selection.EntireRow.Hidden
'Worksheets("sheet4").Colu
MYNUM = Range("partners").Value
MINROWNO = 25
MINCOLUMN = 3
If MYNUM > 0 Then
Do
Rows(MINROWNO).Hidden = False
COUNTER = COUNTER + 1
MINROWNO = MINROWNO + 1
Loop Until COUNTER = MYNUM
End If
End Sub
If someone can crack that, then there will be a follow up question, as I also need to do an unhide columns in another sheet within the 'Do Loop Until' section.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
mikerees,
Cheers for the points :)
To avoid the problem of people renaming sheets, you can use the name of the worksheet 'object' instead of the worksheet 'name'. This is seen in the Project Explorer in the VB editor. They are the one's not in brackets. So you could use something like this....
Sheet4.Columns("C:N").Hidd
Regards,
Wayne
Business Accounts
Answer for Membership
by: ampapaPosted on 2006-01-03 at 06:21:18ID: 15598908
Give this a try, replace with your own workshett names.
= True
mns("C:N") .Hidden = True
Private Sub SpinButton1_Change()
Dim MYNUM As Integer
Dim MINROWNO As Integer
Dim MINCOLUMN As Integer
Dim COUNTER As Integer
Dim sh As Worksheet
For Each sh In Worksheets
If sh.CodeName = "Sheet2" Or sh.CodeName = "Sheet3" Then
Rows("25:49").Select
Selection.EntireRow.Hidden
'Worksheets("sheet4").Colu
MYNUM = Range("partners").Value
MINROWNO = 25
MINCOLUMN = 3
If MYNUM > 0 Then
Do
Rows(MINROWNO).Hidden = False
COUNTER = COUNTER + 1
MINROWNO = MINROWNO + 1
Loop Until COUNTER = MYNUM
End If
End If
Next sh
End Sub
ampapa,