ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Identifying Top row (https://www.excelbanter.com/excel-programming/320514-identifying-top-row.html)

Teresa

Identifying Top row
 
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 Ogilvy

Identifying Top row
 
Range("Y" & Cells(Rows.Count, 1).End(xlUp).Row).Value = "GM"

--
Regards,
Tom Ogilvy

"teresa" wrote in message
...
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






Alan Beban[_2_]

Identifying Top row
 
Tom Ogilvy wrote:
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

Tom Ogilvy

Identifying Top row
 
Thanks, misread the question.

--
Regards,
Tom Ogilvy

"Alan Beban" wrote in message
...
Tom Ogilvy wrote:
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




Harlan Grove

Identifying Top row
 
"Alan Beban" wrote...
....
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"




All times are GMT +1. The time now is 05:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com