I'm trying to capture the row and column numbers of a ranger in variables.
After a fair amount of googling, it seems I might have to store these as Longs and not Integers, but not sure. Either way I get the same "438 object doesn't support this property or method" error when I reach the line "r1 = wb.ws1.Range("CI14").Row" as below.
Dim wb As Workbook
Set wb = Application.Workbooks("test.xlsm")
Dim ws1 As Worksheet
Set ws1 = wb.Worksheets("Worksheet1")
Dim r1 As Long
r1 = wb.ws1.Range("CI14").Row
Dim c1 As Long
c1 = wb.ws1.Range("CI14").Column
Dim rng1 As Range
Set rng1 = wb.ws1.Cells(r1, c1)
I am trying to get something I can iterate on in a while loop, like so:
Do Until IsEmpty(rng1.Value)
(conditional statement)
r1 = r1 + 1
Set rng1 = wb.ws1.Cells(r1, c1)
Loop
ws1
is an object, it is not a Method or Property of your wb
object.
The correct syntax is:
r1 = ws1.Range("CI14").Row
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.