Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default dyanmic range

I am trying to plot a graph in VBA using a selected range.
However I only want the range to incorporate column A and D, which will
expand over time.

How Can I express the following so that the range updates dynamically when
new rows are entered?
Range("A1:A23,D1:D23").Select

Tried this, but does not work at all:
Range(Range("A1").End(xlDown), Range("D1").End(xlDown)).Select

Thank you.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default dyanmic range

Steve,

This should work:

range(range("A1"), range("A1").End(xlDown).Resize(,4)).Select

John

"Steve" wrote in message
...
I am trying to plot a graph in VBA using a selected range.
However I only want the range to incorporate column A and D, which will
expand over time.

How Can I express the following so that the range updates dynamically when
new rows are entered?
Range("A1:A23,D1:D23").Select

Tried this, but does not work at all:
Range(Range("A1").End(xlDown), Range("D1").End(xlDown)).Select

Thank you.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default dyanmic range

Try this

Range("A1:D" & Range("D1").End(xlDown).Row).Select


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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default dyanmic range

Steve,

Just for clarification.....
My example will give select the range based on the last cell in
column "A" (looking downward) while mudrakers will select you
the range based on the last cell in Column "D" (looking downward).

Having looked at the posts, the following is yet another way:
(There are plenty of other ways to do this, I'm sure.)

range("A1").currentregion.Resize(,4).Select

The above uses A1 as a starting point and selects the entire
contiguous range of cells and then just resizes the columns
to 4.

John

"Steve" wrote in message
...
I am trying to plot a graph in VBA using a selected range.
However I only want the range to incorporate column A and D, which will
expand over time.

How Can I express the following so that the range updates dynamically when
new rows are entered?
Range("A1:A23,D1:D23").Select

Tried this, but does not work at all:
Range(Range("A1").End(xlDown), Range("D1").End(xlDown)).Select

Thank you.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default dyanmic range

Try this,

Sub Test()
Dim LRow As Long
LRow = Range("a1").End(xlDown).Row
Range("A1:A" & LRow & ",D1:D" & LRow).Select
End Sub


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


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
How do I enter formula sum(range+range)*0.15 sumif(range=3) tkw Excel Discussion (Misc queries) 2 October 1st 09 09:17 PM
Cond. Format Data Bars of range based on values of another range alexmo Excel Worksheet Functions 4 January 16th 09 04:03 AM
Excel Addin:Setting the range to the Excel.Range object range prop Rp007 Excel Worksheet Functions 5 November 24th 06 04:30 PM
formula to sort a range so that it matches the exact rows of a column that is outside that range? steveo Excel Discussion (Misc queries) 1 June 18th 06 02:05 AM
how to? set my range= my UDF argument (range vs. value in range) [advanced?] Keith R[_3_] Excel Programming 2 August 11th 03 05:55 PM


All times are GMT +1. The time now is 02:00 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"