I am trying to write a macro that will select a changing range. I am trying to use the Range("A1:B2") command, but the ending range can be a different column. I have used the xlToLeft and Activecell.Offset commands to find my last column, but don't know how to reference it in the Range formula. The code errors off at Range("D125:'lastcol'").select
Sample of my code:
Dim lastcol As Long
Range("IV138").Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(0, -1).Select
lastcol = ActiveCell.FormulaR1C1
Range("D125:'lastcol'").Select
Selection.ClearContents
Thanks in advance for all the help.
Sample of my code:
Dim lastcol As Long
Range("IV138").Select
Selection.End(xlToLeft).Select
ActiveCell.Offset(0, -1).Select
lastcol = ActiveCell.FormulaR1C1
Range("D125:'lastcol'").Select
Selection.ClearContents
Thanks in advance for all the help.