Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Macro Help

Status
Not open for further replies.

frantzx

Technical User
Jan 7, 2008
23
US
I have a question regarding macros. I built a macro in the order I want things done in my work book. But for some reason when I run the macro it will do the last part first, then it will run the rest of the macro.I think it may be doing this because the last part of my macro is a quicker process than the rest? I dont know. How do I prevent this? Below is my macro:

Sub test()
'
' test Macro
'

'
Sheets("Adhocs in odd locations").Select
Columns("B:B").Select
Selection.ClearContents
Sheets("Total").Select

ActiveWorkbook.RefreshAll



Sheets("Adhocs in odd locations").Select
Range("A1").Select
Selection.TextToColumns Destination:=Range("A1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(15, 1)), TrailingMinusNumbers:=True
Range("A3").Select
Selection.TextToColumns Destination:=Range("A3"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(19, 1)), TrailingMinusNumbers:=True
Range("A5").Select
Selection.TextToColumns Destination:=Range("A5"), DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 1), Array(19, 1)), TrailingMinusNumbers:=True
Sheets("Total").Select
End Sub



The section that starts with "Sheets("Adhocs in odd locations")." is the part that will load first, I need it to load last.

Thanks in advance for your help.


Brian
 


Brian,

Please post macro (VBA) questions in Forum707.

Skip,

[glasses] When a diminutive clarvoyant had disappeared from detention, headlines read...
Small Medium at Large[tongue]
 
Howdy,

I'm a little confused: I'm assuming you want the stuff after ActiveWorkbook.RefreshAll to run last...? In your post you say the section that begins with Sheets("Adhocs in odd locations") but there are two sections that start with that.

I would suggest doing this: open up the macro to see your code and hit F8. Using F8 you can run the code line by line and that should give you an idea as to what's going on when it's run.

Hope that helps!
prgmrgirl

 
Sorry yes that Is what I meant, everything after ActiveWorkbook.RefreshAll. I'll give the f8 a shot and see whats happening....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top