VBA to select Line charts and format

kpatel89

New Member
Joined
Oct 8, 2013
Messages
3
Hello,

I have just really started to code on VBA but mainly from looking through such forums and using code from other macro's.

I have the following problem and feel i am just missing one simple piece of the puzzle as they say.

I need a macro when activated will do the following;

will look at the active sheet,

look at all the graphs,

select only the line graphs
(on the line graphs there might be 1 to 3 series, generally named after financial years e.g. 2012/13, 2013/14, 2014/15)

Will prompt the use to input the current financial year

from this information the macro will select the series the use has inputted in the step above.

Will then format this series ( i have the code to format to my specification)

Then ideally need the reversal so can turn the dashes back to connected lines.

So far the code i have is the following:</SPAN>


Code:
Sub New_year_LineChart()

 nCharts = ActiveSheet.ChartObjects.Count
   For iChart = 1 To nCharts
   ActiveSheet.ChartObjects(iChart).Activate   

   If ActiveChartObjects(iChart).ChartType = xline Then
               
        
    .Weight = xlMedium
    .LineStyle = xlNone
        
    .MarkerBackgroundColorIndex = 12
    .MarkerForegroundColorIndex = 12
    .MarkerStyle = xlDash
    .Smooth = False
    .MarkerSize = 7
    .Shadow = False
        
        
      End If
     ActiveWindow.Visible = False
    Windows("Test.xls").Activate

        Next
                      
End Sub

i think i am missing the link between activating all the chartobjects, making excel do an "IF chartype = xline, then function"..... format


Thanks for responses and sorry for my lack of skills :(
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
No answers should be a clue. What you ask for is not possible. If you want the user to select a particular chart and then have the ability to re-produce it with whatever formatting.... that would likely be within the realm of possibilties. Good luck. Dave
 
Upvote 0
Thanks Dave I know it was a slightly ambitious

i have now adjusted the approach and now just have one sticking point so will be posting that as a separate post.</SPAN>
 
Upvote 0

Forum statistics

Threads
1,216,117
Messages
6,128,935
Members
449,480
Latest member
yesitisasport

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