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, 2022 in Others by Kithuzzz
• 38,010 points
224 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, 2022 in Others by narikkadan
• 63,700 points
640 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, 2022 in Others by narikkadan
• 63,700 points
967 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, 2022 in Others by narikkadan
• 63,700 points
972 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, 2022 in Others by narikkadan
• 63,700 points
277 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, 2022 in Others by narikkadan
• 63,700 points
4,032 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, 2022 in Others by narikkadan
• 63,700 points
1,839 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, 2022 in Others by narikkadan
• 63,700 points
2,460 views
0 votes
1 answer

Name for excel graph problem with the vba generator

Change the name of the workbook : Sub Macro_name_graph2() ...READ MORE

answered Jan 7, 2023 in Others by narikkadan
• 63,700 points
513 views
0 votes
1 answer

Automating production of graphs using VBA

You have to change: chrtname = Cells(i, 2).Value To: chrtname ...READ MORE

answered Jan 23, 2023 in Others by narikkadan
• 63,700 points
498 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,740 points
955 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