Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default VB coding to go to last cell at end of any given row?

i.e., if one is on cell, say, D3, the code to go to M3, the last cell
in that row. Or, another example, If one is one cell E56 in a sheet,
coding to go to the last cell on that row of, say, T56? So what I'm
asking is that no matter where on any given row was in on, that the
coding take one to the end of that very row.

Thanks!

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default VB coding to go to last cell at end of any given row?

activecell.end(xltoright)

see reference <end under vba help


StargateFan wrote in message
...
i.e., if one is on cell, say, D3, the code to go to M3, the last cell
in that row. Or, another example, If one is one cell E56 in a sheet,
coding to go to the last cell on that row of, say, T56? So what I'm
asking is that no matter where on any given row was in on, that the
coding take one to the end of that very row.

Thanks!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default VB coding to go to last cell at end of any given row?

If there are gaps in the data, this approach may not work.
Try:
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Select

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"R.VENKATARAMAN" $$$ wrote in message
...
activecell.end(xltoright)

see reference <end under vba help


StargateFan wrote in message
...
i.e., if one is on cell, say, D3, the code to go to M3, the last cell
in that row. Or, another example, If one is one cell E56 in a sheet,
coding to go to the last cell on that row of, say, T56? So what I'm
asking is that no matter where on any given row was in on, that the
coding take one to the end of that very row.

Thanks!





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default VB coding to go to last cell at end of any given row?

On Sat, 29 Jan 2005 19:39:20 +1300, "Rob van Gelder"
wrote:

If there are gaps in the data, this approach may not work.
Try:
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Select


Yes, the coding below (activecell.end(xltoright)) didn't work as there
are gaps in the row. Not each cell has information in this contact
list spreadsheet has information in it, nor will it ever, as not
everyone has info to be used (i.e., not everyone has or has provided a
cell phone # or email, for example, so these cells remain blank <g. )

The code above works very well, it's pretty neat. However, if there
is nothing in the last cell(s) in the row I'm in, it scoots back to
the first cell in that row. Or, if there is information in that row,
it goes to the last item of text in it, only. I've found that since
that is the case, I need to refine the definition of what I need <g.
So, it really means that one needs to go to the last cell of the row
I'm working in _whether_or_not_ there is any data after the text in
the actual cell I'm in. The whole purpose of this macro is to go to
that last cell of the row in order to type in data, since this cell in
particular _always_ needs info in it. It's out of the way way at the
end of the row but that also was on purpose as it may or may not be
needed for printing (if not in print range, I'll live with the macro
taking me to the last cell in the print range, which means the one
just before this last cell if we have to have it out of print range
but there to help manipulate data). It's because this cell is a
definition cell for sorting later on as it describes the region the
person in the contact list is in so it provides a necessary bit of
information.

Thanks so much!

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"R.VENKATARAMAN" $$$ wrote in message
...
activecell.end(xltoright)

see reference <end under vba help


StargateFan wrote in message
...
i.e., if one is on cell, say, D3, the code to go to M3, the last cell
in that row. Or, another example, If one is one cell E56 in a sheet,
coding to go to the last cell on that row of, say, T56? So what I'm
asking is that no matter where on any given row was in on, that the
coding take one to the end of that very row.

Thanks!





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VB coding to go to last cell at end of any given row?

It sounds like you already know what the last column is and that column
doesn't appear to be dynamic so

cells(activecell.row,"AB").Select

replace AB with the actual column you want to go to

if this is not the case, which row will always have a value in the last
column (such as row 1 containing headers). In such a case

cells(ActiveCell.row, cells(1,256).End(xltoLeft).Column).Select

--
Regards,
Tom Ogilvy




"StargateFan" wrote in message
...
On Sat, 29 Jan 2005 19:39:20 +1300, "Rob van Gelder"
wrote:

If there are gaps in the data, this approach may not work.
Try:
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Select


Yes, the coding below (activecell.end(xltoright)) didn't work as there
are gaps in the row. Not each cell has information in this contact
list spreadsheet has information in it, nor will it ever, as not
everyone has info to be used (i.e., not everyone has or has provided a
cell phone # or email, for example, so these cells remain blank <g. )

The code above works very well, it's pretty neat. However, if there
is nothing in the last cell(s) in the row I'm in, it scoots back to
the first cell in that row. Or, if there is information in that row,
it goes to the last item of text in it, only. I've found that since
that is the case, I need to refine the definition of what I need <g.
So, it really means that one needs to go to the last cell of the row
I'm working in _whether_or_not_ there is any data after the text in
the actual cell I'm in. The whole purpose of this macro is to go to
that last cell of the row in order to type in data, since this cell in
particular _always_ needs info in it. It's out of the way way at the
end of the row but that also was on purpose as it may or may not be
needed for printing (if not in print range, I'll live with the macro
taking me to the last cell in the print range, which means the one
just before this last cell if we have to have it out of print range
but there to help manipulate data). It's because this cell is a
definition cell for sorting later on as it describes the region the
person in the contact list is in so it provides a necessary bit of
information.

Thanks so much!

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"R.VENKATARAMAN" $$$ wrote in message
...
activecell.end(xltoright)

see reference <end under vba help


StargateFan wrote in message
...
i.e., if one is on cell, say, D3, the code to go to M3, the last cell
in that row. Or, another example, If one is one cell E56 in a sheet,
coding to go to the last cell on that row of, say, T56? So what I'm
asking is that no matter where on any given row was in on, that the
coding take one to the end of that very row.

Thanks!









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default VB coding to go to last cell at end of any given row?

On Sat, 29 Jan 2005 10:35:53 -0500, "Tom Ogilvy"
wrote:

It sounds like you already know what the last column is and that column
doesn't appear to be dynamic so

cells(activecell.row,"AB").Select

replace AB with the actual column you want to go to


Excellent!

if this is not the case, which row will always have a value in the last
column (such as row 1 containing headers). In such a case


No, that's it, exactly, in this case. It works great! I now have
another piece of coding I can use again and again, thank you!!

cells(ActiveCell.row, cells(1,256).End(xltoLeft).Column).Select


I'll also try this out, too.

Cheers!

--
Regards,
Tom Ogilvy




"StargateFan" wrote in message
.. .
On Sat, 29 Jan 2005 19:39:20 +1300, "Rob van Gelder"
wrote:

If there are gaps in the data, this approach may not work.
Try:
Cells(ActiveCell.Row, Columns.Count).End(xlToLeft).Select


Yes, the coding below (activecell.end(xltoright)) didn't work as there
are gaps in the row. Not each cell has information in this contact
list spreadsheet has information in it, nor will it ever, as not
everyone has info to be used (i.e., not everyone has or has provided a
cell phone # or email, for example, so these cells remain blank <g. )

The code above works very well, it's pretty neat. However, if there
is nothing in the last cell(s) in the row I'm in, it scoots back to
the first cell in that row. Or, if there is information in that row,
it goes to the last item of text in it, only. I've found that since
that is the case, I need to refine the definition of what I need <g.
So, it really means that one needs to go to the last cell of the row
I'm working in _whether_or_not_ there is any data after the text in
the actual cell I'm in. The whole purpose of this macro is to go to
that last cell of the row in order to type in data, since this cell in
particular _always_ needs info in it. It's out of the way way at the
end of the row but that also was on purpose as it may or may not be
needed for printing (if not in print range, I'll live with the macro
taking me to the last cell in the print range, which means the one
just before this last cell if we have to have it out of print range
but there to help manipulate data). It's because this cell is a
definition cell for sorting later on as it describes the region the
person in the contact list is in so it provides a necessary bit of
information.

Thanks so much!

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"R.VENKATARAMAN" $$$ wrote in message
...
activecell.end(xltoright)

see reference <end under vba help


StargateFan wrote in message
...
i.e., if one is on cell, say, D3, the code to go to M3, the last cell
in that row. Or, another example, If one is one cell E56 in a sheet,
coding to go to the last cell on that row of, say, T56? So what I'm
asking is that no matter where on any given row was in on, that the
coding take one to the end of that very row.

Thanks!







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB Coding johnsail Excel Discussion (Misc queries) 1 February 18th 10 12:54 PM
Color Coding cell based on date (over a large range) Randy1360 New Users to Excel 3 January 29th 10 09:56 PM
hard coding a cell darrelly Excel Discussion (Misc queries) 2 October 7th 05 11:24 PM
"=ROW()-1" type of coding doesn't appear in a filter / is there coding that does? StargateFan[_3_] Excel Programming 10 October 6th 05 01:18 PM
Coding help fpd833 Excel Programming 2 November 12th 04 08:22 PM


All times are GMT +1. The time now is 04:33 PM.

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

About Us

"It's about Microsoft Excel"