Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting / Selecting Rows when last Row # is unknown

Status
Not open for further replies.

LokiOfGameSlave

Technical User
May 1, 2002
36
CA
Otay ... I've searched high and low for the answer to this and haven't been able to come up with the last bit of coding.

Using Excel 97.

A B
1 Client1 George
2 Client2 Peter
3 Client3 Henry
.
.
.

The user enters records in to the spreadsheet / database. There is no set amount of records that the user will enter. What I want to do after the user has finished entering the data is to go the the last row in the database, select the full row and then highlight up to row 1.

The coding that I have right now is incomplete as I have no clue what to use to get the last little bit.

Selection.End(xlDown).Offset(1, 0).Select
Selection.Rows.EntireRow.Select


The above will move the cursor to the last row and Select / Highlight the Row. Now what do I have to add to get it to highlight the last row and then continue up to Row 1, thereby highlighting the full range?

TIA,
-Loki

Pronunciation: 'lO-kE
Function: noun
Etymology: Old Norse
Definition: a Norse god who contrives evil and mischief for his fellow gods
 
Here's an easy way to select all used rows:
[blue]
Code:
   ActiveSheet.UsedRange.EntireRow.Select
[/color]

 
Assuming there will be a record in Col A for every row used:-

Range(Range("A1"), Range("A" & Rows.Count).End(xlUp)).EntireRow.Select

Regards
Ken...............
 
The problem with that is that I will be using another part of the spreadsheet (as yet undefined) for other information and I don't want those rows selected.

Plus I have the Title of the spreadsheet, a few buttons, etc...

When I tried the code you provided it highlighted from the last row of used rows up to the top of the spreadsheet (where I currently have my title, etc..).

I didn't add that I had a title and buttons, etc... because I didn't think it was pertinent to this question. Sorry. :
Pronunciation: 'lO-kE
Function: noun
Etymology: Old Norse
Definition: a Norse god who contrives evil and mischief for his fellow gods
 
Your example showed data beginning in row 1:

A B
1 Client1 George
2 Client2 Peter
3 Client3 Henry
.
.
.

And your requested stipulated:

....go the the last row in the database, select the full row and then highlight up to row 1....

We're not mind readers.

Now, if you care to describe in sufficient detail just what it is that you are trying to do, maybe someone here can help you.

 
Harsh Zathras, harsh. :( I have difficulty getting across what I want. I will endeavour to detail out sufficiently what I am looking for in the future. :) Please don't not answer my posts in the future as I value everyone's input. I learn more and more from every post.

Ken thank you that did exactly what I was looking for.

Pronunciation: 'lO-kE
Function: noun
Etymology: Old Norse
Definition: a Norse god who contrives evil and mischief for his fellow gods
 
LOL - Hi Zathras, I'm glad it's not just me - thought I was losing it there for a minute. <g>

Regards
Ken................
 
OK - I just twigged - Be careful that you don't then put any data in Col A anywhere past the last record you want included, as if you do, the line I gave you will pick up those rows as well.

Regards
Ken.................
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top