Search : in
By :

Variable range graph

Last answer on Nov 9, 2009 12:44:20 pm GMT rukid, on Jun 29, 2009 5:27:55 pm BST 
 Report this message to moderators

Hello,
I am trying to make a macro in excel that makes graphs from a variable range. This is what I have so far and I don't know why it does work.


Sub Macro1()
'
' Macro1 Macro
'

'
Range("A5").Select
Range(Selection, Selection.End(xlDown)).Select
n = Range("A5", Range("A5").End(xlDown)).Count
Range("D5").Activate
f = Range(Selection, Selection.End(xlDown)).Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range(n, f) 'it fails here
ActiveChart.ChartType = xlXYScatterSmoothNoMarkers
End Sub


I've tried many different things and I don't know how to put in a range that will select to the last non empty cell in a column.
Thank you so much for your help.

Configuration: Windows XP
Firefox 3.0.11
excel 2007

Best answers for « variable range graph » in :
[VBA/VB6] My Documents + Environment Variables Show[VBA/VB6] My Documents + Environment Variables With VBA With VB6 Environment Functions Windows Variables Getting started As displayed in Windows Explorer, the My Documents folder appears to be in the root, but it is not the case. It...
[VBA] Deleting a word in a range of cell Show[VBA] Deleting a word in a range of cell In the case you want to delete a word in a sentence, just create a small macro that removes the word. But it will become difficult when you have word like, for example, "Theword" or "THEWORD" or...
How to read a RealMedia Variable (RMVB) Bitrate file ShowHow to read a RealMedia Variable (RMVB) Bitrate file What is a RMVB file? How to read a RealMedia Variable Bitrate file Convert a RealMedia File Using EO Video What is a RMVB file? RMVB is the acronym used for RealMedia Variable...
Download AVS Media Player ShowAVS media Player is an universal DVD, VIDEO & AUDIO Player: Supporting a very wide variety of video formats : the entire range of MPEG-4 (including DivX, Xvid, etc.), MPEG-1, MPEG-2, AVI, Real Media video, Quick Time files, WMV files (including...
Environment variables ShowEnvironment variables An environment variable is a dynamic value loaded into the memory that can be used by several processes operating simultaneously. On most operating systems, the location of some libraries or of the main system executables may...
Motherboard ShowIntroduction to motherboards The primary component of a computer is the motherboard (sometimes called the "mainboard"). The motherboard is the hub which is used to connect all of the computer's essential components. As its name suggests,...
Introduction to Wi-Fi (802.11 or WiFi) ShowIntroduction to Wi-Fi (802.11) The IEEE 802.11 specification (ISO/IEC 8802-11) is an international standard describing the characteristics of a wireless local area network (WLAN). The name Wi-Fi (short for "Wireless Fidelity", sometimes incorrectly...

1

Excelguru, on Jun 30, 2009 11:17:29 am BST

Hi rukid
Instead of Range(n, f) use Range("A5:D" & n) Winners are losers who got up and gave it one more try. -Dennis DeYoung
My Interests are financial Modelling and custom excel development.

Reply to Excelguru

2

rukid, on Jul 1, 2009 3:24:45 pm BST

Hey thank you for the reply,
I tried what you suggested but it does not work as the columns that the data are in are not from a through d continuously, they are in a,d,f,h,j do you know of a remedy for this? Thank you again.

Reply to rukid

3

rukid, on Jul 1, 2009 3:39:24 pm BST

The other issue that I just noticed is that if I change the length of the data meaning make the columns have more or less data, the macro does not change the range to encompass the whole column. Thanks for any help.

Reply to rukid

4

 roheet, on Nov 9, 2009 12:44:20 pm GMT

My dear friend , i know it sounds stupid for me to reply but if u try this code
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
ActiveSheet.Shapes.addChart.Select
jusat try and will this surve youe purpose

Reply to roheet