Fill & Filter in VBA

  • Thread starter Thread starter Jorge Mario Casasola Salguero
  • Start date Start date
J

Jorge Mario Casasola Salguero

Hello,

I have a Worksheet with some data, that i need to filter,
and after that fill one column from 1 to the number or
rows visibles.

Thanks for any help.
 
With your data table (a sample in B2:D10 (Including headers in Row2)) -
Column A empty:
Place in a Standard Module

Sub test()
counter = 1
rw = 3 ' <<< refers to row number of your 1st row
of your actual data
While ActiveSheet.Cells(rw, 2).Value <> ""
If ActiveSheet.Rows(rw).Hidden = True Then
ActiveSheet.Cells(rw, 1).Value = 0
Else
ActiveSheet.Cells(rw, 1).Value = counter
counter = counter + 1
End If
rw = rw + 1
Wend
Columns("A:A").Select ' << This is the Column you want the row seq
entered
Selection.NumberFormat = "General"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
End With
MsgBox ("Done")
End Sub

Change ranges accordingly..
HTH
 
Back
Top