ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help Defining a range using variables for column (https://www.excelbanter.com/excel-programming/427860-help-defining-range-using-variables-column.html)

mikeb

Help Defining a range using variables for column
 
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


Jim Thomlinson

Help Defining a range using variables for column
 
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))

--
HTH...

Jim Thomlinson


"mikeb" wrote:

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


Gary''s Student

Help Defining a range using variables for column
 
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

--
Gary''s Student - gsnu200850


"mikeb" wrote:

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



All times are GMT +1. The time now is 12:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com