Automated Plotting of User Selected Data

excelmatt

New Member
Joined
Feb 15, 2012
Messages
8
Dear all,

I have a large set of data. I want the user to be able to click the first and last row of data which they wish to plot. I am getting errors on the range of the selected data. Any suggestions welcomed.

Thanks,
Matt

VBA Code below:

Sub plot_selected_date()
Dim rng2 As Range

Set rng2 = Application.InputBox(prompt:="Select the date from which you wish to plot", Type:=8)

Dim rng3 As Range

Set rng3 = Application.InputBox(prompt:="Select the date up until you wish to plot", Type:=8)

add2 = rng2.Address
add3 = rng3.Address

MsgBox add2

Dim tleft As Range
Set tleft = rng2.Offset(0, 2)

Dim bright As Range
Set bright = rng3.Offset(0, 7)
'Dim box As Range
'Set box = Range(tleft:bright)


MsgBox tleft.Address
MsgBox bright.Address

' Range("add2:add3,tleft:bright").Select
'Range("C1").Activate
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("tleft:bright")
ActiveChart.ChartType = xlLine
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).

Forum statistics

Threads
1,214,929
Messages
6,122,317
Members
449,081
Latest member
tanurai

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