xcel VBA Chart counting and formatting

0 votes

I want to develop a macro that counts the number of charts inside a specified range and then takes different actions based on the number. How would I change activesheet.chartobjects.count such that it only counts within a range rather than throughout the entire sheet?

Here's the skeleton of my code.

Sub chrt_chck()
    Dim rng As Range
    Dim x As Long
    Set rng = Range("A1:F10")
    x = ActiveSheet.rng.ChartObjects.Count
    
    If x > 1 Then
    'select and delete all charts in range
    End If
    
    If x = 1 Then
    'select that chart and update format
    Else
    'create chart and set format
    End If
End Sub
Oct 31 in Others by Kithuzzz
• 20,660 points
24 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In Others

0 votes
1 answer

Excel VBA if file closed, then open and paste, else just paste data

Slightly re-worked to add full workbook/sheet qualifiers ...READ MORE

answered Sep 21 in Others by narikkadan
• 37,660 points
88 views
0 votes
1 answer

VBA, Query Vertica database and populate to excel

You can query Vertica directly from excel. I ...READ MORE

answered Sep 25 in Others by narikkadan
• 37,660 points
87 views
0 votes
1 answer

Thousand and million formatting for negative numbers (excel/ googlesheets)

Its not possible. What you could do is ...READ MORE

answered Sep 25 in Others by narikkadan
• 37,660 points
64 views
0 votes
1 answer

Creating a chart in VBA with 2 different Types

Can you carry this out by hand ...READ MORE

answered Oct 11 in Others by narikkadan
• 37,660 points
48 views
0 votes
1 answer

How can I find and replace text in Word using Excel VBA?

Try this code Option Explicit Const wdReplaceAll = 2 Sub ...READ MORE

answered Oct 15 in Others by narikkadan
• 37,660 points
104 views
0 votes
1 answer

Create a pie chart of ages, showing under 30's, 30-50's, and over 50's

Two things: A pie chart does not aggregate ...READ MORE

answered Oct 18 in Others by narikkadan
• 37,660 points
71 views
0 votes
1 answer

How to modify Powerpoint Chart ChartData by Excel VBA

Example: Code: Set pptApp = GetObject(, "PowerPoint.Application") Set pptPres = ...READ MORE

answered Oct 16 in Others by narikkadan
• 37,660 points
119 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,720 points
452 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
2,219 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9 in Others by gaurav
• 22,040 points
69 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP