View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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!