Identifying Top row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 20 rows,


if the first row is the 5th row e.g.A5 or B5,
then I want Y5 = "GM" ETC.ETC.

So something like:

Y(Cells(Rows.Count, 1).End(xlUp).Row)= "GM"

obviously not End(xlUp).Row but something similar

Thks
 
Tom said:
Range("Y" & Cells(Rows.Count, 1).End(xlUp).Row).Value = "GM"
Doesn't do it; if you want the first row in Column A to control try

Range("Y" & Range("A1").End(xlDown).Row).Value = "GM"

If you want Column B to control, change the A1 to B1

Alan Beban
 
Alan said:
Doesn't do it; if you want the first row in Column A to control try

Range("Y" & Range("A1").End(xlDown).Row).Value = "GM"

If you want Column B to control, change the A1 to B1

Alan Beban
And if it isn't known whether Column A or B should be the control, one
might try

Range("Y" & Application.Min(Range("A1").End(xlDown).Row, _
Range("B1").End(xlDown).Row)).Value = "GM"

Alan Beban
 
Alan Beban said:
Doesn't do it; if you want the first row in Column A to control try

Range("Y" & Range("A1").End(xlDown).Row).Value = "GM"

If you want Column B to control, change the A1 to B1

Doesn't work if A1 (or B1) is the only nonblank cell in its column. And if
A1:A# were all nonblank, this would give the bottommost row in that range of
nonblank cells.

If col A should control, shouldn't this be

Range("Y" & IIf(IsEmpty(Range("A1").Value), _
Range("A1").End(xlDown).Row, 1)).Value = "GM"
 

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

Back
Top