Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Macros
Excel Tutorials For Macros

Create a Column Chart with a Macro in Excel


Bookmark and Share

This macro adds a column chart to Excel. This is an easy to use macro that allows you to quickly chart and graph a range of data in Excel. This is a small macro that will create the column chart from a range or set of data that you have in your worksheet. The ranges are hard-coded into the macro.

To use this macro, you only need to replace 'Sheet1'!$A$1:$B$67 with the range or cell references that contain your source data in Excel.
Where to install the macro:  Module

Excel Macro to Create a Column Chart

Sub Create_Column_Chart()
'create a column chart with this excel macro

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("'Sheet1'!$A$1:$B$67")
ActiveChart.ChartType = xlColumnClustered

End Sub


Bookmark and Share


How to Install the Macro
  1. Select and copy the text from within the grey box above.

  2. Open the Microsoft Excel file in which you would like the Macro to function.

  3. Press "Alt + F11" - This will open the Visual Basic Editor - Works for all Excel Versions.  Or For other ways to get there, Click Here.

      For Excel Versions Prior to Excel 2007
      Go to Tools > Macros > Visual Basic Editor

      For Excel 2007
      Go to Office Button > Excel Options > Popular > Click Show Developer tab in the Ribbon. Then go to the Developer tab on the ribbon menu and on the far left Click Visual Basic

  4. On the new window that opens up, go to the left side where the vertical pane is located. Locate your Excel file; it will be called VBAProject (YOUR FILE'S NAME HERE) and click this.

  5. If the Macro goes in a Module, Click Here, otherwise continue to Step 8.

    1. Go to the menu at the top of the window and click Insert > Module
    2. Another window should have opened within the Visual Basic Editor's window. Within this new window, paste the macro code. Make sure to paste the code underneath the last line of anything else that is in the window.
    3. Go to Step 8.

  6. If the Macro goes in the Workbook or ThisWorkbook, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Then, at the bottom of the list that appears, double-click the ThisWorkbook text.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Go to Step 8.

  7. If the Macro goes in the Worksheet Code, Click Here, otherwise continue to Step 8.

    1. Directly underneath your excel file called VBAProject(your file's name here), click the Microsoft Excel Objects folder icon to open that drop-down list.
    2. Within the list that appears you will see every worksheet that is in that excel file. They will be listed as such: Sheet1(NAME OF SHEET HERE) and under that will be Sheet2(NAME OF SHEET HERE). Select the sheet in which you want the macro to run and double-click that sheet.
    3. A new window inside the Visual Basic Editor's window will appear. In this new window, paste the code for the macro. Make sure to paste this code underneath the last line of any other code which is already in the window.
    4. Repeat steps b and c for every sheet you want the macro to work in. Putting the macro in one sheet will not enable it for any other sheets in the workbook.
    5. Go to Step 8.

  8. Close the Microsoft Visual Basic Editor window and save the Excel file. When you close the Visual Basic Editor window, the regular Excel window will not close.

  9. You are now ready to run the macro.



Similar Helpful Excel Resources

Macro To Create Control Chart In Excel - Excel

View Content
Hello:

I wanted to create a macro that would create a control chart from an Excel data set I have which shows survey score information for individuals during a time period.

The data set has 3 fields: persons name being evaluated, a survey score, and the year/month that survey was received. (Note that multiple surveys can happen in a given month).

I would like to be able to run a macro that will evaluate the data, by individual, and create a control chart showing their score, upper control limit (UCL), lower control limit (LCL) and mean, by month. The title would need to show their name and the date range of the surveys being evaluated.

I looked at some off the shelf software and macros, and even those would require a lot of manual input to create them, so I think a customized macro is the way to go.

I would greatly appreciate it if someone could provide some guidance and asssitance towards doing this.

Many thanks in advance-
Ebachenh

How Do You Create A Pivot Table Chart Using A Macro In Excel 2007 - Excel

View Content

I want to create a pivot table chart using a Macro in excel. The problem that I am having is formatting the chart. I can't get it to adjust the size shape and position of the chart when i am recording the macro. Any suggestion?

Macro To Find Chart And Delete Chart And Create Chart - Excel

View Content
Hi guys,

Good day. I am trying a macro which i found online which finds the availability of a sheet, delete it if its found an can create the same sheet again.

Sub test_delete_add_sheet()
Application.DisplayAlerts = False
Dim sh As Worksheet, flg As Boolean
For Each sh In Worksheets
If sh.Name Like "Sheet1*" Then flg = True: Exit For
Next

If flg = True Then
Sheets("Sheet1").Delete
Else
Sheets.Add
ActiveSheet.Name = "Sheet1"
End If
End Sub

I wanted to do the same to find a chart and deleting it and creating it if an user specifies it in order to save space in my spreadsheet. Can anyone advice me on this?

Vba Macro To Create A Repeating Series Of Numbers In An Excel Column - Excel

View Content
I am trying to write a macro/VBA that looks at A1, A2, and A3, where A1= starting number, A2=the range, and A3=the number of iterations. If A1=1, A2=4, and A3=3, I want to fill B1 with:
1
2
3
4
1
2
3
4
1
2
3
4

I have this so far:
Sub filler()
Dim length
Dim start
Dim iterations
start = Worksheets("Sheet1").Cells(1, "A").Value
MsgBox (start)
length = Worksheets("Sheet1").Cells(2, "A").Value
MsgBox (length)
iterations = Worksheets("Sheet1").Cells(3, "A").Value
MsgBox (iterations)
Range("B1") = start
Range("B1").DataSeries Rowcol:=xlColumns, Type:=xlLinear, Date:=xlDay, _
step:=start, Stop:=start * length, Trend:=False
End Sub

Create Floating Column Chart - Excel

View Content
I need to create a chart that shows verticle columns. I have 3 data points, for each i need a verticle col that goes from the lower bound to the upper bound. How do you do that. Here is my data:

Lower Bound Upper Bound
A 1 5
B 3 12
C 5 17

Create Chart When Only Column Is Dates - Excel

View Content
Sorry if the answer to this is out there, but I've searched a bunch and haven't hit on the right topic.

I have a spreadsheet that only has dates in it. It's a huge version of this:

5/24/2004
5/26/2004
6/1/2004
6/10/2004
6/10/2004
7/5/2004
7/6/2004

In reality there are many entries (some on the same day, some not) for each day from 5/1/2004 to now.

I'm trying to find a way to make that usable by grouping and counting each entry per month, either by a list that says:

May 2004 2
June 2004 3
July 2004 2

or as a chart. I sure can't figure out a way to do either, so I'm hoping someone here can help out. I'm using Office for Mac 2011, but I can use Excel 2003 - 2010 on the PC side if I need to.

Thanks,
Gabe

How To Create A Stacked Column Chart - Excel

View Content
I can't figure out how to create a stacked column chart in Excel 2007. For example: I have a set of data: data1 1,000; data2 2,000; data3 3,000; total 6,000. How can I create a simple stacked column from these data?

Create Stacked Column Chart - Excel

View Content
Dears,

Hope that you all are good.

Attached fine contain a graph for different types of product with a number of quantity sold for each product along with their amounts.

My question is that is there a way to show only 1 pillar for each product which indicate at the main axis the quantity sold and the secondary axis the amount of sold quantities?

I would like to have one pillar per product instead of two.

How To Create Dynamic Column Chart? - Excel

View Content
this is the data source i have:
s_id Team suppliername 14 Material Costing elec 14 Material Costing elec 14 Material Costing elec 14 Material Costing elec 14 Material Costing elec 14 Tactical elec 14 Tactical elec 14 Tactical elec 14 Tactical elec 14 Tactical elec 15 Material Costing mechanical 15 Material Costing mechanical 15 Material Costing mechanical 15 Material Costing mechanical 15 Material Costing mechanical 15 Tactical mechanical 15 Tactical mechanical 15 Tactical mechanical 15 Tactical mechanical 15 Tactical mechanical

i need to create few column charts which based on the suppliername, in the example above mean i need to create 2 column charts, and i have build some coding buy jz able to create the 1st chart only
Code:

Dim IngRows As Long
Dim x As Integer
IngRows = Range("A2").CurrentRegion.Rows.Count

For x = 2 To IngRows - 1
If Not (Cells(x, 3).Text = Cells(x + 1, 3).Text) Or IsEmpty(Cells(x + 3, 3).Text) Then
Range(Cells(2, 1), Cells(x, 7)).Select

ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range(Cells(2, 1), Cells(x, 7)), PlotBy:=xlColumns
ActiveChart.ChartType = xlColumnClustered
ActiveWindow.SmallScroll Down:=-3

End If

Next x


is so weird that the loop will end once it met the if condition, instead of continue, how can I make it to continue loop and build the rest of the chart?
Thanks for help.

Create A Chart From A Column Of Dates - Excel

View Content
Hi there! I have a column of dates. (It's from a w/s of sales, and each row is the date of a sale.) Some rows have the same date as others, which means there was more than one sale on that date. So I simply want to create a chart which shows the number of sales for each date.

A second column indicates whether a promotion was running on that date. If a promotion was running on that date, then the cell shows "promo". If not, it's empty. I would like the promo dates plotted on the chart too.

Random Tutorials
Extract Text from Cells - Intermediate Example
(Intermediate)
Remove #N/A Error Result from Empty VLOOKUP() Formulas
(Intermediate)
Introduction to Making Formulas in Excel
(Easy)
IF Statement Introduction & Using Nested IF's
(Easy)
HLOOKUP() Function - Introduction
(Intermediate)
AND(), OR(), and IF() Statements/Formulas
(Intermediate)
Submit Inquiry Here
  • Prices From $10
Name:*
E-mail:*
Request:*
The macro(s) on this page will be sent with the request.
Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com