Dear experts
I am trying to wirte a could that uses labels in columns to define the start and the end of a range. So far I have the following code. Running into some trouble when I try to define the range , v in the code below. v is meant to be the range define using the start and end indexes found.
Please help, been at this for awhile
Kuda
Tags:
vba
I am trying to wirte a could that uses labels in columns to define the start and the end of a range. So far I have the following code. Running into some trouble when I try to define the range , v in the code below. v is meant to be the range define using the start and end indexes found.
Please help, been at this for awhile
Kuda
Code:
'Defines the range, based on column labels
Sub findrange()
Dim level As Integer
Dim levels As Integer
Dim levelrange As Variant
levelrange = Worksheets("Sheet1").Range("a4:z4")
'Crange = Sheets("Sheet1").Range("b5:j15")
levels = 4
i = 1
levelstart = i
'Range Start
Worksheets("Sheet1").Range("a4:z4").Select
Selection.Find(What:=levelstart, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
With Selection
srow = .Row
scol = .Column
End With
levelend = i + 1
'range end
Worksheets("Sheet1").Range("a4:z4").Select
Selection.Find(What:=levelend, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Select
With Selection
eRow = .Row
ecol = .Column - 1
End With
v = "range" & i = ".range(.cells(" & scol & "," & srow+1 & "),.cells(" &scol& ",65000)"
End Sub
Tags:
vba