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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help - VB Excel query

Status
Not open for further replies.

kev777

Technical User
Nov 18, 2001
9
GB
I am exporting an Excel Macro into a VB app but keep getting errors. I want the Macro to run in the current open xl workbook. Do I need any code before the macro? Here is some of the macro:

Sheets("Model").Select
Columns("IV:IV").Select
Selection.ClearContents
Columns("AD:AD").Select
Selection.Insert Shift:=xlToRight
Columns("G:G").Select
Selection.Copy
Columns("AD:AD").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Sheets("Copy").Select
Application.Goto Reference:="copy"
Selection.Copy

Thanks,

Kev.
 
hi Kev,

From ur code what i understand is you want to run the macro on the sheet named "Model". However if you want it to run on sheet which is currently Open/Active try using -"ActiveSheet" Property. i.e

ActiveSheet.Select
ActiveSheet.Columns("IV:IV").Select
Selection.ClearContents
ActiveSheet.Columns("AD:AD").Select
Selection.Insert Shift:=xlToRight

Hope this solves ur problem

Cheers!!!
Niraj >:):O>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top