Selecting AutoFilter Rows

G

Guest

Hi,
I have a Filter in a spreadsheet and want to create a code in order to
select each visible row and change its content.
I have visible rows 2,3,4,10,15,50....3560,6550, etc
What code should I write to in order to select each row change its value and
continue till the end of the visible rows.
Regards
Pedro
 
G

Guest

Thanks

But that will select all the range
I want to select each cell in A column and then change the value of it, then
it will continue doing it till the end of the shown rows

regards
 
K

KL

then do this:

With ActiveSheet.AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible).Count = 1 Then
MsgBox "no visible cells"
Else
.Columns(1).Cells.SpecialCells(xlCellTypeVisible).Select
End If
End With

KL
 
D

Dave Peterson

Are you changing all the values in that visible range in column A to the same
thing?

Option Explicit
Sub Tester03()
Dim rng As Range

With ActiveSheet.AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible).Count = 1 Then
MsgBox "no visible cells"
Else
Set rng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
rng.Value = "hi there"
End If
End With
End Sub

This doesn't select anything--it just changes the values.

Or are you changing each cell to a different value?

Option Explicit
Sub Tester03B()
Dim rng As Range
Dim myCell As Range
Dim iCtr As Long

With ActiveSheet.AutoFilter.Range
If .Columns(1).Cells.SpecialCells(xlCellTypeVisible).Count = 1 Then
MsgBox "no visible cells"
Else
Set rng = .Resize(.Rows.Count - 1, 1).Offset(1, 0) _
.Cells.SpecialCells(xlCellTypeVisible)
iCtr = 1
For Each myCell In rng.Cells
myCell.Value = iCtr 'something that changes
iCtr = iCtr + 1
Next myCell
End If
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top