ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Range Replace (https://www.excelbanter.com/excel-programming/375255-range-replace.html)

Rewop Eilsel[_2_]

Range Replace
 
The following macro works well as two seperate halves but fails when joined
together
Range(ActiveCell, ActiveCell.Offset(2, 0)).Select
Selection.EntireRow.Select.Replace What:=Range("AB28"), _
Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

The first half works, but the second half (from "Replace...") comes back
with the comment "Run Time Error 424" & " Object required", can anyone please
help?

Rewop Eilsel

Jim Thomlinson

Range Replace
 
Try something more like this...

Range(ActiveCell, ActiveCell.Offset(2, 0)).EntireRow.Replace _
What:=Range("AB28"), _
Replacement:="", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
--
HTH...

Jim Thomlinson


"Rewop Eilsel" wrote:

The following macro works well as two seperate halves but fails when joined
together
Range(ActiveCell, ActiveCell.Offset(2, 0)).Select
Selection.EntireRow.Select.Replace What:=Range("AB28"), _
Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

The first half works, but the second half (from "Replace...") comes back
with the comment "Run Time Error 424" & " Object required", can anyone please
help?

Rewop Eilsel


Rewop Eilsel[_2_]

Range Replace
 
Thanks Jim, your suggestion works beautifully
Regards
Rewop Eilsel

"Rewop Eilsel" wrote:

The following macro works well as two seperate halves but fails when joined
together
Range(ActiveCell, ActiveCell.Offset(2, 0)).Select
Selection.EntireRow.Select.Replace What:=Range("AB28"), _
Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False

The first half works, but the second half (from "Replace...") comes back
with the comment "Run Time Error 424" & " Object required", can anyone please
help?

Rewop Eilsel



All times are GMT +1. The time now is 10:37 AM.

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