ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Fill & Filter in VBA (https://www.excelbanter.com/excel-programming/272270-fill-filter-vba.html)

Jorge Mario Casasola Salguero

Fill & Filter in VBA
 
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.







JMay

Fill & Filter in VBA
 
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

"Jorge Mario Casasola Salguero" wrote in message
...
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.










All times are GMT +1. The time now is 11:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com