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 |
Macro- Column Insert
On the spreadsheet that I was working with columns had been grouped. After I
ungrouped them the macro worked to only insert one column. Thanks for your help. "Toppers" wrote: 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 |
All times are GMT +1. The time now is 11:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com