View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default use a variable to set a range

With ActiveSheet
Set LastCell = .Cells.SpecialCells(xlCellTypeLastCell)
LastCell.EntireColumn.Insert Shift:=xlToLeft
End With

"Excel_VBA_Newb" wrote:

How do I perform this:

'Obtain last column that contains data
lastCol = ActiveSheet.UsedRange.Column - 1 +
ActiveSheet.UsedRange.Columns.Count

'Convert to Alpha
(code omitted for brievity)

'Define the Column in the range based on the previous check
Range(lastCol:lastCol).Insert Shift:=xlToLeft

Thanks.