Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 3rd, 2003, 04:08 AM
a_munro a_munro is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2003
Posts: 9 a_munro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Testing for the last column in the spreadsheet

I require to search through a row of a spreadsheet picking out values to populate a combobox. Each value is seperated by 4 or 5 empty cells. My problem is, to perform the test of the while loop, how do I know when I have reached the last column? ie when there are no value after that.

Thanks
Andy

Reply With Quote
  #2  
Old July 3rd, 2003, 05:13 PM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 96 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 44 m 59 sec
Reputation Power: 9
Hi,

I do something similar to find the bottom row, as follows: -

<snip>
Dim objBottomRow As Object
Dim intBottomRow As Integer

Sheets("sheet-name").Select
Set objBottomRow = Worksheets("sheet-name").Cells.SpecialCells(xlCellTypeLastCell)

intBottomRow = objBottomRow.Row
</snip>

Just did a quick hack and "objBottomRow.Column" will (I think) give what you need (you'll need to translate the number returned to "A", "B", etc.).

(Note that to ensure Excel resets the value of the last cell, you need to save the workbook with the current selection as "A1").

HTH

Reply With Quote
  #3  
Old July 5th, 2003, 11:47 AM
epl epl is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2001
Location: Dublin
Posts: 413 epl User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 18 m 18 sec
Reputation Power: 8
what versions of excel does that work for? (resetting the last cell)

Reply With Quote
  #4  
Old July 5th, 2003, 01:14 PM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 96 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 44 m 59 sec
Reputation Power: 9
"what versions of excel does that work for? (resetting the last cell) "

Definitely works in 2K (9.0.2720) – I’m pretty sure I’ve also used it in ’97.

Just tested it (in 2K) and it appears you no longer have to be positioned in A1 before doing the save (perhaps that was only necessary in ’97).

Last edited by NicMic : July 5th, 2003 at 01:24 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Testing for the last column in the spreadsheet


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway