ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using .Replace (https://www.excelbanter.com/excel-programming/302703-using-replace.html)

Jason Morin[_2_]

Using .Replace
 
How can I find and replace for a certain range? I'd
rather not use Cells.Replace.... and search the entire
sheet:

Sub Worksheet_Activate()
Set area = Sheets("Layout-Bulk (2)").Range("A7:BR53")
For Each cell In area
.Replace What:="##", Replacement:="="
Next cell
End Sub

Thx.
Jason

Bernie Deitrick

Using .Replace
 
Jason,

It is a bad idea to use variables that are used within the Object Model
(area is one)

Dim myArea As Range
Set myArea = Sheets("Layout-Bulk (2)").Range("A7:BR53")
myArea.Replace ....

HTH,
Bernie
MS Excel MVP

"Jason Morin" wrote in message
...
How can I find and replace for a certain range? I'd
rather not use Cells.Replace.... and search the entire
sheet:

Sub Worksheet_Activate()
Set area = Sheets("Layout-Bulk (2)").Range("A7:BR53")
For Each cell In area
.Replace What:="##", Replacement:="="
Next cell
End Sub

Thx.
Jason




Leo Heuser[_3_]

Using .Replace
 
Hi Bernie

"Area" is OK to use. It's not used in the object model.
I believe you mean "Areas".

--
Best Regards
Leo Heuser

Followup to newsgroup only please.

"Bernie Deitrick" <deitbe @ consumer dot org skrev i en meddelelse
...
Jason,

It is a bad idea to use variables that are used within the Object Model
(area is one)

Dim myArea As Range
Set myArea = Sheets("Layout-Bulk (2)").Range("A7:BR53")
myArea.Replace ....

HTH,
Bernie
MS Excel MVP





All times are GMT +1. The time now is 03:20 AM.

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