Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range question in VB

I have a spreadsheet with data in column A starting from A5 ... list o
my pH reading for my aquarium. I also have a chart graphing this data
Right now my data start at A5 and end at A11.

Right now I have created a macro in VB that allow me input the las
cell of my data (example A12, A15), and then used that range (e.g
A5:A15, if I entered A15) to update my graph.

I was wondering if anyone knew how to retrieve the range using VB o
the selected cells. Another word, I want VB to return startig range A
and ending range A15 if I selected A5:A15. I can then use that info t
update my chart thus giving me more flexibility.

Any help would be appreciated

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 340
Default Range question in VB

To return the first cell in a selection:

dim firstCell as range
set firstCell = selection.cells(1)
msgbox firstCell.address

for the last cell:

dim lastCell as range
with selection
set lastcell = .cells(.cells.count) 'note the period in front of cells
end with
msgbox lastcell.address

Bob Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"rohnds " wrote in message
...
I have a spreadsheet with data in column A starting from A5 ... list of
my pH reading for my aquarium. I also have a chart graphing this data.
Right now my data start at A5 and end at A11.

Right now I have created a macro in VB that allow me input the last
cell of my data (example A12, A15), and then used that range (e.g.
A5:A15, if I entered A15) to update my graph.

I was wondering if anyone knew how to retrieve the range using VB of
the selected cells. Another word, I want VB to return startig range A5
and ending range A15 if I selected A5:A15. I can then use that info to
update my chart thus giving me more flexibility.

Any help would be appreciated.


---
Message posted from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default Range question in VB

Another handy tool that might be of use. Assuming the range
starts at A5 and there are at least 2 data points. The end of
the range can be found by:
"A" & Range("A5").End(xlDown).Row
"Bob Flanagan" wrote in message
...
To return the first cell in a selection:

dim firstCell as range
set firstCell = selection.cells(1)
msgbox firstCell.address

for the last cell:

dim lastCell as range
with selection
set lastcell = .cells(.cells.count) 'note the period in front of

cells
end with
msgbox lastcell.address

Bob Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel


"rohnds " wrote in message
...
I have a spreadsheet with data in column A starting from A5 ... list of
my pH reading for my aquarium. I also have a chart graphing this data.
Right now my data start at A5 and end at A11.

Right now I have created a macro in VB that allow me input the last
cell of my data (example A12, A15), and then used that range (e.g.
A5:A15, if I entered A15) to update my graph.

I was wondering if anyone knew how to retrieve the range using VB of
the selected cells. Another word, I want VB to return startig range A5
and ending range A15 if I selected A5:A15. I can then use that info to
update my chart thus giving me more flexibility.

Any help would be appreciated.


---
Message posted from http://www.ExcelForum.com/





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Range question in VB

Thank you. This was exactly what I was looing for

--
Message posted from http://www.ExcelForum.com

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
Range question in '97 Adam Kroger Excel Discussion (Misc queries) 10 December 12th 05 03:44 AM
Used Range Question a Excel Programming 2 May 26th 04 03:45 AM
Range question Lee dengo Excel Programming 2 May 25th 04 09:41 PM
If Range.Name question Otto Moehrbach[_5_] Excel Programming 8 November 30th 03 11:05 PM
Range.Formula and Range question using Excel Automation [email protected] Excel Programming 0 September 19th 03 04:53 AM


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