ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Changing visible (filtered) cells (https://www.excelbanter.com/excel-programming/331373-changing-visible-filtered-cells.html)

Edwin Niemoller

Changing visible (filtered) cells
 
Hello group,

I'm using the following code on a selected range to change the cell value
into "paid"

Worksheets("sales").Range("invoices").Select

For Each cell In Selection
If Not IsEmpty(cell.Value) Then
If cell.Value < "Paid" Then
cell.Value = "Paid"
End If
End If
Next cell

However I would also like it to work when the range is filtered, meaning
only on the visible cells.

I hope someone can get me going

Thanks

Edwin



STEVE BELL

Changing visible (filtered) cells
 
Try this:

==============
Range("A1:D25").SpecialCells(xlCellTypeVisible).Se lect
====================
For Each cell In
Worksheets("sales").Range("invoices").SpecialCells (xlCellTypeVisible)
=================
--
steveB

Remove "AYN" from email to respond
"Edwin Niemoller" wrote in message
...
Hello group,

I'm using the following code on a selected range to change the cell value
into "paid"

Worksheets("sales").Range("invoices").Select

For Each cell In Selection
If Not IsEmpty(cell.Value) Then
If cell.Value < "Paid" Then
cell.Value = "Paid"
End If
End If
Next cell

However I would also like it to work when the range is filtered, meaning
only on the visible cells.

I hope someone can get me going

Thanks

Edwin





Edwin Niemoller

Changing visible (filtered) cells
 
Thanks Steve, works like a charm!

Edwin

"STEVE BELL" wrote in message
news:Qn0qe.16127$yS2.11442@trnddc07...
Try this:

==============
Range("A1:D25").SpecialCells(xlCellTypeVisible).Se lect
====================
For Each cell In
Worksheets("sales").Range("invoices").SpecialCells (xlCellTypeVisible)
=================
--
steveB

Remove "AYN" from email to respond
"Edwin Niemoller" wrote in message
...
Hello group,

I'm using the following code on a selected range to change the cell

value
into "paid"

Worksheets("sales").Range("invoices").Select

For Each cell In Selection
If Not IsEmpty(cell.Value) Then
If cell.Value < "Paid" Then
cell.Value = "Paid"
End If
End If
Next cell

However I would also like it to work when the range is filtered, meaning
only on the visible cells.

I hope someone can get me going

Thanks

Edwin







STEVE BELL

Changing visible (filtered) cells
 
Glad to be of help...

Happy Exceling...

P.S.
I got the code by recording a macro, than editing it...

--
steveB

Remove "AYN" from email to respond
"Edwin Niemoller" wrote in message
...
Thanks Steve, works like a charm!

Edwin

"STEVE BELL" wrote in message
news:Qn0qe.16127$yS2.11442@trnddc07...
Try this:

==============
Range("A1:D25").SpecialCells(xlCellTypeVisible).Se lect
====================
For Each cell In
Worksheets("sales").Range("invoices").SpecialCells (xlCellTypeVisible)
=================
--
steveB

Remove "AYN" from email to respond
"Edwin Niemoller" wrote in message
...
Hello group,

I'm using the following code on a selected range to change the cell

value
into "paid"

Worksheets("sales").Range("invoices").Select

For Each cell In Selection
If Not IsEmpty(cell.Value) Then
If cell.Value < "Paid" Then
cell.Value = "Paid"
End If
End If
Next cell

However I would also like it to work when the range is filtered,
meaning
only on the visible cells.

I hope someone can get me going

Thanks

Edwin










All times are GMT +1. The time now is 11:54 AM.

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