Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Inaccurate LAST ROW / LAST COLUMN #

PROBLEM: cannot accurately determine Last Row / Last Column on worksheet
using either of the two code sets below

CAUSE: worksheet is a "shell" into which new files are pasted each month.
They vary in both # of Rows and Columns each month. I delete rows and columns
of prior month as a first step in macro. (I cannot close and re-open the
worksheet - doesn't work either!)

WHAT MAKES ME CRAZY! The resulting #s will be prior month's total rows and
columns IF the prior month's file was larger. I've used the code sets below
but neither accurately determines the last Row / Last Column. I must be
missing something really basic (every pun intended!)
All advice will be gratefully appreciated.'




CODE SETS:
'
FinalRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
FinalColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
'
'
FinalRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
'
FinalColumn = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
'
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Inaccurate LAST ROW / LAST COLUMN #

Try these two statements instead...

FinalRow = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious).Row

FinalColumn = ActiveSheet.Cells.Find(What:="*", SearchOrder:=xlByColumns, _
SearchDirection:=xlPrevious).Column

--
Rick (MVP - Excel)


"KG Old Wolf" wrote in message
...
PROBLEM: cannot accurately determine Last Row / Last Column on worksheet
using either of the two code sets below

CAUSE: worksheet is a "shell" into which new files are pasted each month.
They vary in both # of Rows and Columns each month. I delete rows and
columns
of prior month as a first step in macro. (I cannot close and re-open the
worksheet - doesn't work either!)

WHAT MAKES ME CRAZY! The resulting #s will be prior month's total rows and
columns IF the prior month's file was larger. I've used the code sets
below
but neither accurately determines the last Row / Last Column. I must be
missing something really basic (every pun intended!)
All advice will be gratefully appreciated.'




CODE SETS:
'
FinalRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
FinalColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
'
'
FinalRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
'
FinalColumn = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
'


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Inaccurate LAST ROW / LAST COLUMN #

Hi

To reset last used row/column use 'ActiveSheet.UsedRange' before you
determine last row/column

ActiveSheet.UsedRange
FinalRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
FinalColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column

Regards,
Per

On 23 Sep., 21:39, KG Old Wolf
wrote:
PROBLEM: cannot accurately determine Last Row / Last Column on worksheet
using either of the two code sets below

CAUSE: worksheet is a "shell" into which new files are pasted each month.
They vary in both # of Rows and Columns each month. I delete rows and columns
of prior month as a first step in macro. *(I cannot close and re-open the
worksheet - doesn't work either!)

WHAT MAKES ME CRAZY! The resulting #s will be prior month's total rows and
columns IF the prior month's file was larger. I've used the code sets below
but neither accurately determines the last Row / Last Column. I must be
missing something really basic (every pun intended!)
All advice will be gratefully appreciated.'

CODE SETS:
'
FinalRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
FinalColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
'
'
FinalRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
'
FinalColumn = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
'


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Inaccurate LAST ROW / LAST COLUMN #

Guys -

thank for the effort but if you look back at the two code snippets I
provided, you will notice that they appear to be the same code as you each
suggested... and that doesn't work.

The problem is now fixed with the insertion of a preceeding line of simple

--- ActiveWorkbook.Save
FinalRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
FinalColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column

Thanks and I hope this solution helps others...
Ken





"KG Old Wolf" wrote:

PROBLEM: cannot accurately determine Last Row / Last Column on worksheet
using either of the two code sets below

CAUSE: worksheet is a "shell" into which new files are pasted each month.
They vary in both # of Rows and Columns each month. I delete rows and columns
of prior month as a first step in macro. (I cannot close and re-open the
worksheet - doesn't work either!)

WHAT MAKES ME CRAZY! The resulting #s will be prior month's total rows and
columns IF the prior month's file was larger. I've used the code sets below
but neither accurately determines the last Row / Last Column. I must be
missing something really basic (every pun intended!)
All advice will be gratefully appreciated.'




CODE SETS:
'
FinalRow = ActiveCell.SpecialCells(xlCellTypeLastCell).Row
FinalColumn = ActiveCell.SpecialCells(xlCellTypeLastCell).Column
'
'
FinalRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlRows).Row
'
FinalColumn = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, _
SearchOrder:=xlByColumns).Column
'

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
inaccurate line chart Tom H. Charts and Charting in Excel 3 December 3rd 09 03:22 PM
Comparing two lists with one being inaccurate Ditch Excel Discussion (Misc queries) 3 June 24th 09 02:57 PM
sum inaccurate Terry Excel Worksheet Functions 4 March 16th 09 08:43 AM
How do you correct inaccurate sumif totals? Analyst Excel Worksheet Functions 2 August 15th 07 11:59 PM
R1C1 to A1 inaccurate formula conversion markx Excel Programming 2 August 8th 06 04:32 PM


All times are GMT +1. The time now is 05:09 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"