PDA

View Full Version : [SOLVED:] Search Column and skip hidden rows



werner123
04-12-2017, 04:01 AM
Good day
Can someone please assist , Macro needs to skip (Pass) hidden rows and only work on visible rows , without the SpecialCells(xlCellTypeVisible) ,Macro work fine but it includes hidden rows


Sub create


BeginRow = 5
EndRow = 1000
ChkCol = 47


For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).SpecialCells(xlCellTypeVisible).value = True Then 'Get type mismacth error

Cells(RowCnt, ChkCol).Select

Cells(Application.ActiveCell.row, 21).value = 1


End If

Next RowCnt
End Sub




Thank you

GTO
04-12-2017, 04:44 AM
I just used column A for the range, but maybe something like:



Sub create()
Const OffsetNumber As Long = 5
Dim Cell As Range


For Each Cell In Sheet1.Range("A5:A1000").SpecialCells(xlCellTypeVisible)
If Cell.Value = True Then
Cell.Offset(, OffsetNumber).Value = 1
End If
Next
End Sub


I did not worry about the offset, which if I am reading your code correctly, would be a negative number.

Mark

werner123
04-12-2017, 05:50 AM
Awesome , thank you so much , works perfectly

GTO
04-12-2017, 06:39 AM
Happy to help and welcome to VBAX :hi: