View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default Macro- Column Insert

It doesn't insert two columns: it deletes 4 (E:H), moves G2 to H2, adds the
text "new one" to G2.

Perhaps this:

Sub Problem()
'
' Problem Macro
' Macro recorded 8/16/2007
'
' Keyboard Shortcut: Ctrl+Shift+P
'

Columns("E:H").Delete Shift:=xlToLeft
Columns("G:G").Insert Shift:=xlToRight
Range("G2").FormulaR1C1 = "new one"
With Range("G2").Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With

End Sub
"lostatlewisu" wrote:



"lostatlewisu" wrote:

After recording a macro that inserts a column in a worksheet, I run it and it
inserts two columns. I don't understand why?


Sub Problem()
'
' Problem Macro
' Macro recorded 8/16/2007
'
' Keyboard Shortcut: Ctrl+Shift+P
'
Columns("E:H").Select
Selection.Delete Shift:=xlToLeft
Columns("G:G").Select
Range("G2").Activate
Selection.Insert Shift:=xlToRight
Range("G2").Select
ActiveCell.FormulaR1C1 = "new one"
With ActiveCell.Characters(Start:=1, Length:=7).Font
.Name = "Arial"
.FontStyle = "Bold"
.Size = 8
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("G3").Select
End Sub