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!

Help Converting Macro to Vbscript

Status
Not open for further replies.

krammer

IS-IT--Management
Jul 15, 2007
59
US
I'm having a hard time converting this excel macro into vbscript...it cuts column C and inserts the cells into column B, shifting column B down to C.

Code:
Sub Move_Columns()


    Columns("C:C").Select

    Selection.Cut

    Columns("B:B").Select

    Selection.Insert Shift:=xlToRight

End Sub

I was thinking something similar to this:

Code:
objExcel.Columns("C:C").Cut

But I have not found anything on the web about this...can anyone help?
 
[tt]'Let [blue]osheet[/blue] is the activesheet of the application.
with osheet
.Columns("C:C").Select
.application.Selection.Cut
.Columns("B:B").Select
.application.Selection.Insert -4161 'xlToRight=-4161
end with
[/tt]
 
Thanks tsuji. I will try that when I get in this morning...do you think there is a way to cut it down to 1 line?
 
I can do it like this:

Code:
    objExcel.Columns("C:C").Select
    objExcel.Application.Selection.Cut
    objExcel.Columns("B:B").Select
    objExcel.Selection.Insert -4161

There's gotta be a way to shorten it down to one line...
 
Got it down to two lines...

Code:
    objExcel.Columns("C:C").Cut
    objExcel.Columns("B:B").Insert -4161
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top