Chamberlain
Board Regular
- Joined
- Jan 6, 2006
- Messages
- 149
Here's what I have:
Sub UnhideNonBlankRows()
ActiveSheet.Unprotect
Range("x11").Select
Dim FstRow As Integer
Dim LstRow As Integer
FstRow = "20"
LstRow = "343"
Col = "B"
For i = FstRow To LstRow
If Cells(i, Col) = "2" Then
Cells(i, Col).EntireRow.Hidden = False
End If
Next i
Range("f11").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingRows _
:=False, AllowInsertingHyperlinks:=True, _
AllowSorting:=True, AllowFiltering:=True
End Sub
The problem with this is if you insert rows between the FstRow and LstRow, the row #'s don't change. Basically if I insert a row between 20 and 343, I want the LstRow to become 344. I would imagine that one way to do this would be to make the FstRow and LstRow named ranges (Which I tried), however I'm not good enough with VB to make it work.
Any help would be much appreciated.
Thanks,
Dave
Sub UnhideNonBlankRows()
ActiveSheet.Unprotect
Range("x11").Select
Dim FstRow As Integer
Dim LstRow As Integer
FstRow = "20"
LstRow = "343"
Col = "B"
For i = FstRow To LstRow
If Cells(i, Col) = "2" Then
Cells(i, Col).EntireRow.Hidden = False
End If
Next i
Range("f11").Select
ActiveSheet.Protect DrawingObjects:=False, Contents:=True, Scenarios:= _
False, AllowFormattingCells:=True, AllowFormattingColumns:=True, _
AllowFormattingRows:=True, AllowInsertingRows _
:=False, AllowInsertingHyperlinks:=True, _
AllowSorting:=True, AllowFiltering:=True
End Sub
The problem with this is if you insert rows between the FstRow and LstRow, the row #'s don't change. Basically if I insert a row between 20 and 343, I want the LstRow to become 344. I would imagine that one way to do this would be to make the FstRow and LstRow named ranges (Which I tried), however I'm not good enough with VB to make it work.
Any help would be much appreciated.
Thanks,
Dave