#1   Report Post  
Posted to microsoft.public.excel.misc
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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
insert column macro will incorrectly add another value [email protected] Excel Discussion (Misc queries) 1 March 23rd 07 12:28 PM
Excel macro to insert uncertain numbers of column with different value [email protected] Excel Discussion (Misc queries) 2 March 7th 07 10:12 PM
Excel Macro to Insert the contents of one column to other Dhawal Excel Discussion (Misc queries) 5 October 5th 06 01:22 PM
Trying to insert a column using variable in a Macro MackPetD Excel Discussion (Misc queries) 1 July 25th 06 08:14 AM
Dynamic column insert (macro) Chris Excel Discussion (Misc queries) 2 March 15th 06 11:33 AM


All times are GMT +1. The time now is 11:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"