View Full Version : Solved: find first item in column
av8tordude
07-29-2010, 07:07 AM
Cells(Range("A10009").End(xlUp).Row, 1).Activate
The above code finds the last record in column A. How can I edit this code to find the first record in the same column
austenr
07-29-2010, 07:11 AM
Cells(Range("A10009").End(xlDown).Row, 1).Activate
Bob Phillips
07-29-2010, 07:28 AM
I think Austen meant
Cells(Range("A1").End(xlDown).Row, 1).Activate
av8tordude
07-29-2010, 08:05 AM
I tried to modified the code because I should have included that it should look for the first record starting from Row 9. I tried the code below, but it goes to the last recored in the column.
Cells(Range("A9").End(xlDown).Row, 1).Activate
Bob Phillips
07-29-2010, 08:31 AM
If A9 is populated, it will. Start from A8.
YasserKhalil
07-29-2010, 08:31 AM
Try
Cells(Range("A8").End(xlDown).Row, 1).Activate
av8tordude
07-29-2010, 08:43 AM
I tried that, but it does not give me the results I'm after. I have various data starting from A1-A8, but from A9-A10009 I only have dates. When I filter the sheet to display only certian information, I want the cursor to goto the first record displayed in column A. After filtering, if the first record displayed happens to be on row 259, then the cursor should goto the first record displayed.
Bob Phillips
07-29-2010, 08:47 AM
Then maybe
If Range("A9").Value <> "" Then
Range("A9").Activate
Else
Range("A9").End(xlDown).Activate
End If
av8tordude
07-29-2010, 08:56 AM
Then maybe
If Range("A9").Value <> "" Then
Range("A9").Activate
Else
Range("A9").End(xlDown).Activate
End If
Its close, when the sheet is unfiltered, it goes to A9, but it if after filtering the sheet and the first record after Row 8 is (i.e. Row 159), the cursor should go to Row 159.
vzachin
07-29-2010, 10:10 AM
while this is not the best of coding, see if this works for you
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A2").Resize(iLastRow - 1).SpecialCells(xlCellTypeVisible)
For Each cell In rng
cell.Activate
Exit For
Next cell
av8tordude
07-29-2010, 10:31 AM
while this is not the best of coding, see if this works for you
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng = Range("A2").Resize(iLastRow - 1).SpecialCells(xlCellTypeVisible)
For Each cell In rng
cell.Activate
Exit For
Next cell
PERFECT!!!!!! :friends:
Thank you vzachin and everyone else who contributed!
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.