Moving colC to colA

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to move colC to ColA. I also want colA to not be destroyed. This is
what I'm doing so far. Thanks in advance.


Set objRange = objWorksheet.Range("C1").EntireColumn
objRange.Copy

Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate

Set objRange = objWorksheet.Range("A1")
objWorksheet.Paste (objRange)
 
Mike, this is straight from the macro recorder:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/13/2007 by cchickering
'

'
Columns("C:C").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
End Sub

And this is the same code cleaned up:
Sub Macro1()
Columns("C:C").Cut
Columns("A:A").Insert Shift:=xlToRight
End Sub
 
How would you wirte that in VBScript?

Charles Chickering said:
Mike, this is straight from the macro recorder:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 2/13/2007 by cchickering
'

'
Columns("C:C").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
End Sub

And this is the same code cleaned up:
Sub Macro1()
Columns("C:C").Cut
Columns("A:A").Insert Shift:=xlToRight
End Sub
 
Sub MoveC()
Dim eApp As Object
Dim WB As Object
Dim r As Object
Set eApp = CreateObject(Excel.Application)
Set WB = eApp.Workbooks.Add
WB.Worksheets(1).Columns("C:C").Cut
WB.Worksheets(1).Columns("A:A").Insert Shift:=xlToRight
End Sub

Something along those lines should get a scripting file to work. I'm not
sure exactly what the rest of your code looks like though.
 
Ok that works fine.

Charles Chickering said:
Sub MoveC()
Dim eApp As Object
Dim WB As Object
Dim r As Object
Set eApp = CreateObject(Excel.Application)
Set WB = eApp.Workbooks.Add
WB.Worksheets(1).Columns("C:C").Cut
WB.Worksheets(1).Columns("A:A").Insert Shift:=xlToRight
End Sub

Something along those lines should get a scripting file to work. I'm not
sure exactly what the rest of your code looks like 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