graphing data

jdavis9

Active Member
Joined
Mar 8, 2002
Messages
337
I have several spread sheets which contain the following format:
18 columns of data starting on col b.
"b" contains time and "c" contains data.
Then "D" time "E" data, ect...
The problem is the # of rows changes from one file to the next.
Using a macro, I graph the different data required. However, when the file changes and the total # of rows changes, the graphs either come up with lines for time and the data with a point ref for the x axis when the # of rows is less than the original file or i get particial data when the # of rows is more than the original data.

The question is:
Using macro/VB how do I graph the equiv. of the data selected with the following?

Range("B7:C7").Select
Range(Selection, Selection.End(xlDown)).Select
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

Mark O'Brien

MrExcel MVP
Joined
Feb 15, 2002
Messages
3,530
Something like this should work:

<pre>
Public Sub test()
Dim oRange As Range
Set oRange = GetUsedRange(Sheets("Sheet1").Range("B7:C7"))

'then just use oRange instead of "Selection"
MsgBox oRange.Address
End Sub

Public Function GetUsedRange(ByVal oTargetRange As Range) As Range
Set GetUsedRange = Range(oTargetRange, oTargetRange.End(xlDown))
End Function</pre>

this also gets rid of the need to use "Selection" in your code which can get really messy.

HTH
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,542
Messages
5,832,346
Members
430,128
Latest member
ojl987

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top