Ark68
Well-known Member
- Joined
- Mar 23, 2004
- Messages
- 4,564
- Office Version
- 365
- 2016
- Platform
- Windows
I'm struggling with a relatively easy function in vba. I am trying to find the row number based on the first empty cell in a dynamic range (rng_cntb)
Here is what I have that isn't providing the right answer:
In my testing, mstr_lr_pdr = 36, so therefore rng_cntb = ws_master.range("A13:A36")
The last cell in that range is at A21.
I am expecting a value for x of 22, but I'm getting 77.
Can someone correct my code, or suggest an alternate. I know how to find the last row in an entire worksheet, but not within a defined range.
Here is what I have that isn't providing the right answer:
Code:
Set rng_cntb = ws_master.Range("A13:A" & mstr_lr_pdr)
ws_master.Unprotect
x = rng_cntb.SpecialCells(xlCellTypeLastCell).Row
msgbox "Next available empty row in the available range is: " & x
In my testing, mstr_lr_pdr = 36, so therefore rng_cntb = ws_master.range("A13:A36")
The last cell in that range is at A21.
I am expecting a value for x of 22, but I'm getting 77.
Can someone correct my code, or suggest an alternate. I know how to find the last row in an entire worksheet, but not within a defined range.