Help Defining a range using variables for column

  • Thread starter Thread starter mikeb
  • Start date Start date
M

mikeb

Hi I need to define the range below, column B needs to be replaced with
variable CurCol. How do I do this?

Set rngSource = .Range(.Range("B21"), .Range("B21").End(xlDown))

Thanks,
Mike
 
dim strCol as String
strCol = "B"
Set rngSource = .Range(.cells(21, strcol), .cells(21, strcol).End(xlDown))

I would be more inclined to use xlUp from the bottom of the range in case
there are any blanks but that is up to you...

dim strCol as String
strCol = "B"
Set rngSource = .Range(.cells(21, strcol), .cells(.rows.count,
strcol).End(xlUp))
 
Sub sistence()
Dim s As String
Dim CurCol As String
CurCol = "A"
s = CurCol & "21"
With ActiveSheet
Set rngSource = .Range(.Range(s), .Range(s).End(xlDown))
End With
End Sub
 
Back
Top