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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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
 
Upvote 0

Forum statistics

Threads
1,214,932
Messages
6,122,332
Members
449,077
Latest member
jmsotelo

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
Back
Top