excel macro inconsistency

  • Thread starter Thread starter JM
  • Start date Start date
J

JM

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?
 
Columns("B:B").Select
Selection.Replace What:="-", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False

This code is in a procedure, and is called within the same
module. If I step through the code it works fine.

JM
 
Hi
try:
Activesheet.columns("B:B").Replace What:="-", Replacement:="",
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
 
I figured it out, actually. I was running a query and then
formatting the data, but the query was not finished before
the formatting started. I set the backgroundquery
condition on the refresh command to false, and now ti the
timing is fine. Thanks though!
 

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

Back
Top