First/last row/col

F

Francis Hookham

First/last row/col

I am getting in a terrible muddle trying to find the first and last occupied
row in a particular col and in a row in a particular col

In this particular project data is stored in row 7 starting at column 4 (D7)
And in column 3 starting in row 25 (C25)

Please show me how to find the last col in which data is stored in row 7
And the last row in which data is stored in col C

At the same time how would I find the start col in row 7 and the start row
in col D if they were not known - this will be useful later

Many thanks

Francis Hookham
 
B

Bernard Rey

Francis Hookham wrote :
I am getting in a terrible muddle trying to find the first and last occupied
row in a particular col and in a row in a particular col

Directly in the worksheet hit "Control-Arrow down" (or "Control-Arrow
Right"), but I guess it's in a macro you'd like to know.

In this particular project data is stored in row 7 starting at column 4 (D7)
And in column 3 starting in row 25 (C25)

Please show me how to find the last col in which data is stored in row 7
And the last row in which data is stored in col C

The VBA answer would be something like:
MyLastRow = Range("C25").End(xlDown).Rows.Row
MyLastCol = Range("C25").End(xlToRight).Columns.Column
Supposing you know that your range includes the C25 cell. (you'd get the
same result starting from cell D27, admitting that your range is more than 2
columns wide and more than three rows high)

At the same time how would I find the start col in row 7 and the start row
in col D if they were not known - this will be useful later

The same lines would do, if you change "xlDown" with "xlUp" and "xlToRight"
with "xlToLeft".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top