Link to home
Start Free TrialLog in
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

What value it is having

Hi,
I want to know what value

ConfigWS.Cells(Rows.Count, "C").End(xlUp).Row

is going to have, each time, when running the macro.
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

This will return the last used row number in column C

So if Column C has values in Cells C1, C2 & C3 only this call will return 3
Avatar of Martin Liss
It will return the row number of the last non-blank row in column C of the worksheet that ConfigWS refers to.
Avatar of Peter Chan

ASKER

I try to get value of

ConfigWS.Cells(Rows.Count, "C").End(xlUp).Row

and see its value is 94.

this is the relevant worksheet,
User generated image
it seems it is taking last 2nd value on Column D, but I expect it to retrieve the last value on Column D. what to adjust?
If you want the last row in column C then try

lngLastRow = Range("C1048576").End(xlUp).Row

If you want the last row in column D then try

lngLastRow = Range("D1048576").End(xlUp).Row

In both cases lngLastRow is defined like this

Dim lngLastRow As Long
From what you have posted the call would return 29 and so using this you could do something like

lastRow = ConfigWS.Cells(Rows.Count, "C").End(xlUp).Row
ColDLastEntry = ConfigWS.Range("D" & lastRow).value

Open in new window


Some assumptions here
The sheet in your screenshot is the sheet referenced by ConfigWS
There are no entries outside to scope of your screenshot

From what you are describing the problem is not in the call you have posted but elsewhere in the code. Any chance you could post the workbook for us to look at?
I am not able to refer to this value


Range("D1048576").End(xlUp).Row


Using these

    Dim lastRow As Long
    lastRow = ConfigWS.Cells(Rows.Count, "C").End(xlUp).Row

Open in new window

I see this value


ConfigWS.Range("D" & lastRow).value


is zero.
ASKER CERTIFIED SOLUTION
Avatar of Michael Fowler
Michael Fowler
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial