Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 260
Default Column find code not working correctly

hey

The following code finds the last row used (variable
STACKEDUP) and find the last column used (variable
STACKEDLEFT). STACKEDUP works fine but STACKEDLEFT keeps
showing 256 which is column IV. There is no data in this
column so why does it keep finding it as the last column
with data in it. It should be finding column Z because
thats the last column that has data in it.


Worksheets("Location View").Select
STACKEDUP = Worksheets("Location View").Range("A65536").End
(xlUp).Row
STACKEDLEFT = Worksheets("Location View").Range("h:h").End
(xlToRight).Column


Thanks
Todd
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default Column find code not working correctly

Todd,

Try the analog to what you are doing with finding the last row:

STACKEDLEFT = Worksheets("Location View").Range("IV1").End(xlToLeft).Column

Note that this will find the last used column in Row 1 - adjust as needed.
If you need to find it for a whole range of rows, there have been some
discussions in this group you can google about using the Find method.

hth,

Doug Glancy

"Todd Huttenstine" wrote in message
...
hey

The following code finds the last row used (variable
STACKEDUP) and find the last column used (variable
STACKEDLEFT). STACKEDUP works fine but STACKEDLEFT keeps
showing 256 which is column IV. There is no data in this
column so why does it keep finding it as the last column
with data in it. It should be finding column Z because
thats the last column that has data in it.


Worksheets("Location View").Select
STACKEDUP = Worksheets("Location View").Range("A65536").End
(xlUp).Row
STACKEDLEFT = Worksheets("Location View").Range("h:h").End
(xlToRight).Column


Thanks
Todd



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Column find code not working correctly

Doug Glancy wrote:
Todd,

Try the analog to what you are doing with finding the last row:

STACKEDLEFT = Worksheets("Location View").Range("IV1").End(xlToLeft).Column

Note that this will find the last used column in Row 1 . . . .


Unless the last used column is Column IV. Slightly more general is,
with Worksheets("Location View") selected as you have shown,

STACKEDLEFT = Range("1:1").Find("*", , , , , xlPrevious).Column

Both will return an error message if the row is empty.

Alan Beban
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
If function not working correctly Relle Excel Discussion (Misc queries) 10 September 16th 09 10:42 AM
VLookup is not working correctly Eric @ BP-EVV Excel Worksheet Functions 3 July 18th 08 12:24 AM
Code not working within hidden column range RobN[_2_] Excel Discussion (Misc queries) 1 March 24th 08 09:54 AM
vlookup isn't working correctly? Dave F Excel Discussion (Misc queries) 2 October 14th 06 04:27 AM
Why code for find() is not working jesmin Excel Discussion (Misc queries) 1 December 28th 05 08:43 PM


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