lezawang
Well-known Member
- Joined
- Mar 27, 2016
- Messages
- 1,805
- Office Version
- 2016
- Platform
- Windows
Hi
the code below is to type blah in cell a43 then hide rows 25 to 70 for sheets 1 to 5. it works only for sheet1 and then i get error message "selection method of range class failed"
the code below is to type blah in cell a43 then hide rows 25 to 70 for sheets 1 to 5. it works only for sheet1 and then i get error message "selection method of range class failed"
Code:
Sub fivesheets()
For i = 1 To 5
ThisWorkbook.Worksheets(i).Range("a43").Value = "blah"
ThisWorkbook.Worksheets(i).Rows("25:70").Select
Selection.EntireRow.Hidden = True
Next i
End Sub