View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
tomek tomek is offline
external usenet poster
 
Posts: 13
Default Macro to insert column

some autoformatting spoiled the layout.... it should look like this:

Dim i As Integer
Dim t As Range

' 1)
Set t = Application.InputBox("Click the last column", "Some Title Here", _
Type:=8)
i = t.Column
Columns(i).EntireColumn.Insert

' 2)
i = Application.InputBox("Column number?", "Some Title Here", Type:=1)
Columns(i).EntireColumn.Insert

' 3) finds the last column without asking the user
i = Range("IV1").End(xlToLeft).Column
Columns(i).EntireColumn.Insert

' 4) same here
i = Cells(1, 256).End(xlToLeft).Column
Columns(i).EntireColumn.Insert



"Tomek" wrote in message
...
Hi,
here it goes:

Dim i As Integer
Dim t As Range

Set t = Application.InputBox("Click the last column", "Some Title Here",
Type:=8) ' 1)
i = t.Column
Columns(i).EntireColumn.Insert

i = Application.InputBox("Column number?", "Some Title Here", Type:=1)
' 2)
Columns(i).EntireColumn.Insert

i = Range("IV1").End(xlToLeft).Column
' 3) finds the last column without asking the user
Columns(i).EntireColumn.Insert

i = Cells(1, 256).End(xlToLeft).Column
' 4) same here
Columns(i).EntireColumn.Insert

regards
Tomek