How to insert a column...

  • Thread starter Thread starter aapp81
  • Start date Start date
A

aapp81

i need a bit of clarification with this please:

i need to select col A:B on sheet "Breakdown"
if A:B empty then insert col C from sheet "Data" into A (leaving B
empty)
but, if there's data in A:B, insert 2 columns and move A:B to the right
(so now the data from a:b will be c:d) and insert col C from sheet
"Data"

thanks!
 
works like a charm!

but if anyone can point out flaws, errors or corrections i'd be
greatful as well... :D

Sub IsThere()

Application.ScreenUpdating = False

Sheets("Breakdown").Select
Range("A1:B1").Select
If Selection.Text = "" Then
GoTo Insert
Else
Columns("A:B").Select
Selection.Insert Shift:=xlToRight
End If

Insert:
Sheets("Data").Select
Range("C1").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Breakdown").Select
Range("A2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Columns("A:A").EntireColumn.AutoFit
Range("B2").Select

Application.ScreenUpdating = True

End Sub
 
Back
Top