A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Selecting the first cell of the last row in a range



 
 
Thread Tools Display Modes
  #1  
Old April 3rd, 2009, 02:49 PM posted to microsoft.public.excel.newusers
Susan Ramlet[_3_]
external usenet poster
 
Posts: 137
Default Selecting the first cell of the last row in a range

A co-worker asked me how to programmatically select the first cell of the
last row in a range in Excel 2003 (Windows XP). We found the Help reference
to selecting the last cell in a range, but we couldn't come up with a good
solution for the first cell in the last row, other than a "SendKeys" type of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**


  #2  
Old April 3rd, 2009, 03:17 PM posted to microsoft.public.excel.newusers
Don Guillett
external usenet poster
 
Posts: 6,167
Default Selecting the first cell of the last row in a range

This will find the last row on the active sheet and then select col A in
that row.

Sub firstcelloflastrow()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
'MsgBox lr
Cells(lr, 1).Select
'or
'Cells(lr, 1).End(xlToRight).Select
'to goto the first non blank cell on THAT row

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Susan Ramlet" wrote in message
...
A co-worker asked me how to programmatically select the first cell of the
last row in a range in Excel 2003 (Windows XP). We found the Help
reference
to selecting the last cell in a range, but we couldn't come up with a good
solution for the first cell in the last row, other than a "SendKeys" type
of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**



  #3  
Old April 3rd, 2009, 03:23 PM posted to microsoft.public.excel.newusers
Simon Lloyd[_186_]
external usenet poster
 
Posts: 1
Default Selecting the first cell of the last row in a range


Could you explain why you would want to select the first used cell in a
range or is it the first cell in a range?

Susan Ramlet;295213 Wrote:
A co-worker asked me how to programmatically select the first cell of
the
last row in a range in Excel 2003 (Windows XP). We found the Help
reference
to selecting the last cell in a range, but we couldn't come up with a
good
solution for the first cell in the last row, other than a "SendKeys"
type of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=82520

  #4  
Old April 3rd, 2009, 03:47 PM posted to microsoft.public.excel.newusers
Susan Ramlet[_3_]
external usenet poster
 
Posts: 137
Default Selecting the first cell of the last row in a range

Thank you, Don! We will put this to use. I appreciate the quick and complete
response.

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**


"Don Guillett" wrote in message
...
This will find the last row on the active sheet and then select col A in
that row.

Sub firstcelloflastrow()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
'MsgBox lr
Cells(lr, 1).Select
'or
'Cells(lr, 1).End(xlToRight).Select
'to goto the first non blank cell on THAT row

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Susan Ramlet" wrote in message
...
A co-worker asked me how to programmatically select the first cell of the
last row in a range in Excel 2003 (Windows XP). We found the Help
reference
to selecting the last cell in a range, but we couldn't come up with a
good
solution for the first cell in the last row, other than a "SendKeys" type
of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**




  #5  
Old April 3rd, 2009, 04:28 PM posted to microsoft.public.excel.newusers
Susan Ramlet[_3_]
external usenet poster
 
Posts: 137
Default Selecting the first cell of the last row in a range

He wants to select the first cell of the last row of a range and then format
it programmatically (I don't know the specific objective in the context of
the overall spreadsheet; sorry...).

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**


"Simon Lloyd" wrote in message
...

Could you explain why you would want to select the first used cell in a
range or is it the first cell in a range?

Susan Ramlet;295213 Wrote:
A co-worker asked me how to programmatically select the first cell of
the
last row in a range in Excel 2003 (Windows XP). We found the Help
reference
to selecting the last cell in a range, but we couldn't come up with a
good
solution for the first cell in the last row, other than a "SendKeys"
type of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile:
http://www.thecodecage.com/forumz/member.php?userid=1
View this thread: http://www.thecodecage.com/forumz/sh...ad.php?t=82520


  #6  
Old April 3rd, 2009, 04:35 PM posted to microsoft.public.excel.newusers
Don Guillett
external usenet poster
 
Posts: 6,167
Default Selecting the first cell of the last row in a range

Selecting is NOT necessary
Sub firstcelloflastrow()
lr = Cells.Find("*", Cells(Rows.Count, Columns.Count) _
, , , xlByRows, xlPrevious).Row
'MsgBox lr

Cells(lr, 1).numberformat=???
or
format(Cells(lr, 1), "mm/dd")
'or
'Cells(lr, 1).End(xlToRight).Select
'to goto the first non blank cell on THAT row

End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Susan Ramlet" wrote in message
...
He wants to select the first cell of the last row of a range and then
format it programmatically (I don't know the specific objective in the
context of the overall spreadsheet; sorry...).

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**


"Simon Lloyd" wrote in message
...

Could you explain why you would want to select the first used cell in a
range or is it the first cell in a range?

Susan Ramlet;295213 Wrote:
A co-worker asked me how to programmatically select the first cell of
the
last row in a range in Excel 2003 (Windows XP). We found the Help
reference
to selecting the last cell in a range, but we couldn't come up with a
good
solution for the first cell in the last row, other than a "SendKeys"
type of
solution to send "Ctl-down arrow", which is a bit too imprecise.

Neither of us is a strong coder, but he's trying to use a macro to get
there.

Any ideas would be welcome!

--
Susan Ramlet
**please reply to the newsgroup so others may benefit**



--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (
http://www.thecodecage.com)
------------------------------------------------------------------------
Simon Lloyd's Profile:
http://www.thecodecage.com/forumz/member.php?userid=1
View this thread:
http://www.thecodecage.com/forumz/sh...ad.php?t=82520



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 01:23 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.