Selection -> Range -> Chart

ReeveCZE

New Member
Joined
Jun 8, 2014
Messages
7
Hey guys,

since I am a real loser at using range, I gotta ask you the following.

I want to create a chart from an area of data. Please see the following code and tell me what I am doing wrong.

Many thanks!


Code:
' variables
Dim AAAA as Worksheet
Dim BBBB as Range

'requested range
[COLOR=#000000]Range("A4").Select
[/COLOR][COLOR=#000000]Range(Selection, Selection.End(xlToRight)).Select
[/COLOR][COLOR=#000000]Range(Selection, Selection.End(xlDown)).Select
[/COLOR]
Set AAAA = ActiveSheet
Set BBBB = Selection

Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=AAAA.BBBB, _  'my problem
[COLOR=#000000]'etc etc etc
[/COLOR]
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
This should add your chart with the selection

Code:
Sub Charts()
Dim BBBB As Range
Set BBBB = Selection
With BBBB
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.ChartType = xlLine
    ActiveChart.SetSourceData Source:=BBBB
End With
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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