Macros not recognising moved information

Spook E

New Member
Joined
Aug 15, 2006
Messages
22
In my spreadsheet i have an area for allowing users to enter survey results, at the end of which is a button they can push (with an attached macro) that will display the results of the survey in a pie graph.

The information used by the macro to show the series information is stored in columns at the end of the end of the data entry area

All works well until extra columns are entered in the data entry area, pushing the category label information further across the spreadsheet. As the macro uses this data to display graph category label content, the macro needs to recognise that the data range for this has moved and to move with it (i.e F3:F7 becomes G3:G7). The macro is not picking this change up, and when the button is pressed to generate the graph, the category label information is missed.

How do i make the macro realise that this important information has moved and to ensure it is captured.

Image added, to hopefully make sense of my description :)

236562350_821515637d.jpg
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi there

Name the range, then refer to it by its name.
eg
Select the range then go to Insert / Name / Define and name it "LOC"

In your macro refer to it as Range("LOC")

regards
Derek
 
Upvote 0
I tried that, but when i enter the range name in the graph wizard it gives me an error saying that the Range("jeff") is invalid.
 
Upvote 0
Sub f10chart()
'
' f10chart Macro
' Macro recorded 18/08/2006 by dbadcock
'

'
Charts.Add
ActiveChart.ChartType = xlPie
ActiveChart.SetSourceData Source:=Sheets("Residential Family Survey").Range( _
"I22:K22"), PlotBy:=xlRows
ActiveChart.SeriesCollection(1).XValues = _
"='Residential Family Survey'!R22C19:R22C21"
ActiveChart.SeriesCollection(1).Name = "='Residential Family Survey'!R22C2"
ActiveChart.Location Where:=xlLocationAsObject, Name:= _
"Residential Family Survey"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).ApplyDataLabels AutoText:=True, LegendKey:= _
False, HasLeaderLines:=False, ShowSeriesName:=False, ShowCategoryName:= _
False, ShowValue:=False, ShowPercentage:=True, ShowBubbleSize:=False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,536
Members
449,037
Latest member
tmmotairi

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