ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   excel macro inconsistency (https://www.excelbanter.com/excel-discussion-misc-queries/1546-excel-macro-inconsistency.html)

JM

excel macro inconsistency
 
I recorded a macro which selects a column and then
replaces all instances of "-" with "". I cut and pasted
the recorded code into a larger macro. If I run the macro
it does not execute the replacement, but does not generate
any errors. If I step through the macro via the debugger
the replace executes properly. Anyone know what is going
on? Some kind of timing issue?

Frank Kabel

Hi
post your used code

--
Regards
Frank Kabel
Frankfurt, Germany

"JM" schrieb im Newsbeitrag
...
I recorded a macro which selects a column and then
replaces all instances of "-" with "". I cut and pasted
the recorded code into a larger macro. If I run the macro
it does not execute the replacement, but does not generate
any errors. If I step through the macro via the debugger
the replace executes properly. Anyone know what is going
on? Some kind of timing issue?



Dave Peterson

Just a guess.

Sometimes when I step through the code, I'll be swapping between the VBE and
excel--so the correct worksheet is the activesheet.

If you're trying to run the code against a specific sheet, maybe you're getting
the wrong sheet (using the activesheet instead of the specific one).

with worksheets("sheet1")
cells.replace ....
end with

would work against the activesheet since I omitted the leading dot in front of
..cells:

with worksheets("sheet1")
.cells.replace ....
end with

And if your code is in a worksheet module, maybe you're not doing the correct
sheet, too. An unqualified range will go to the sheet that owns the code--not
the activesheet.



JM wrote:

I recorded a macro which selects a column and then
replaces all instances of "-" with "". I cut and pasted
the recorded code into a larger macro. If I run the macro
it does not execute the replacement, but does not generate
any errors. If I step through the macro via the debugger
the replace executes properly. Anyone know what is going
on? Some kind of timing issue?


--

Dave Peterson


All times are GMT +1. The time now is 12:26 PM.

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