#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro not consistant

I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all the
rows leaving out one or two. Anyone know why?
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro not consistant

Don, do you mean that this fails if my last row is empty on the last column?
That situation can occur. I'm trying to find the last col with anything in
any row and the last row with anything in any col. Sounds confusing but you
probably know what I mean.

If these statements don't do that then how can I fix them?

grok

"Don Guillett" wrote:

Maybe your last column is not the column with the last row?

--
Don Guillett
SalesAid Software

"grok" wrote in message
...
I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all the
rows leaving out one or two. Anyone know why?




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default Macro not consistant

Cells(Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row, Cells.Find("*",
[A1], , , xlByColumns, xlPrevious).Column).Select

--
Regards,
Luc.

"Festina Lente"


"grok" wrote:

I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all the
rows leaving out one or two. Anyone know why?

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default Macro not consistant

Another alternative that works on a completely empty sheet:
activesheet.usedrange.cells(activesheet.usedrange. cells.count).select
--
Regards,
Luc.

"Festina Lente"


"grok" wrote:

I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all the
rows leaving out one or two. Anyone know why?



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 29
Default Macro not consistant

Thanks for trying, PapaDos. But I get compiler errors with both solutions.

grok

"PapaDos" wrote:

Another alternative that works on a completely empty sheet:
activesheet.usedrange.cells(activesheet.usedrange. cells.count).select
--
Regards,
Luc.

"Festina Lente"


"grok" wrote:

I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all the
rows leaving out one or two. Anyone know why?

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 208
Default Macro not consistant

Works fine for me, what errors are you getting ?
--
Regards,
Luc.

"Festina Lente"


"grok" wrote:

Thanks for trying, PapaDos. But I get compiler errors with both solutions.

grok

"PapaDos" wrote:

Another alternative that works on a completely empty sheet:
activesheet.usedrange.cells(activesheet.usedrange. cells.count).select
--
Regards,
Luc.

"Festina Lente"


"grok" wrote:

I'm using these statements in some macros:
lc = Cells(1, Columns.Count).End(xlToLeft).Column
lr = Cells(Rows.Count, lc).End(xlUp).Row
Range(Cells(1, 1), Cells(lr, lc)).Select

Most of the time they work but some of the time they do not select all the
rows leaving out one or two. Anyone know why?

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
error when running cut & paste macro Otto Moehrbach Excel Worksheet Functions 4 August 9th 06 01:49 PM
Compiling macro based on cell values simonsmith Excel Discussion (Misc queries) 1 May 16th 06 08:31 PM
Search, Copy, Paste Macro in Excel [email protected] Excel Worksheet Functions 0 January 3rd 06 06:51 PM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Highlight Range - wrong macro, please edit. Danny Excel Worksheet Functions 8 October 19th 05 11:11 PM


All times are GMT +1. The time now is 10:30 AM.

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"