Create Surface Chart Via Macro Code Based On Selection
May 28, 2008
I want to write a macro to add a surface chart for a Data Range which includes 6000 data points. But the series selected for the chart don't cover all Data Ranges, only part of them.
Public Sub AddChart2(LastRow As Integer, LastCol As Integer)
Dim cht As ChartObject, currentSheet As Worksheet
Dim rng As Range, newRow As Range, srcRange As Range
Dim colIdx As Integer
I would like to do a surface chart which, with the same x and y, there are different z numbers. They can connect to different surface. Could it be possible? To make it clear, I have a 4-dimension Data, z(x,y,a), i want to show on the surface chart that how different 'a' gives the different x-y-z surface. I don't know if it is possible.
I have a table of data which moves up and down my report depending on user input changes to the source data.
I have written some VBA code to generate a chart based on this table of data. I have managed to create a basic chart from this table. However I need to change the series (on the chart) from rows to columns so that it is displayed correctly. For this I need to have the cell references within the code belonging to the actual chart.
If I was writing the code for the chart with an absolute reference I would write it as:
I am working on a manning document which tells me when people report, and depart based on their job position. I have all of the info in one worksheet, and want to generate a bar like graph on another worksheet in the workbook (by just changing the cell color for ease) for a snapshot to view holes in job positions.
The snapshot worksheet has the list of jobs on the left, and months/years in a line acorss the top i.e.
2006 | J | F | M | A | M | J | J | A | S | O | N | D | Job Position X X X X X X Job Position X X X X X X
Here was the code I started with, and it doesn't do anything!
Private Sub Workbook_CreateCalendar(ByVal Sh As Object, ByVal Target As Range)
Dim Firstrow As Long Dim Lastrow As Long Dim Lrow As Long Dim Fcol As Date Dim Lcol As Date Dim Lencol As Long Dim CalcMode As Long Dim ViewMode As Long 'Set the Start Date of your Sheet Dim DatTim1 As Date DatTim1 = #1/1/2006#
The "Sum" sheet can change its number of rows. The pivot table is based on it. I'm having trouble with the SourceData portion of the code in my macro ....
Trying to create an excel chart to create totals based upon different keys. I need to be able to calculate how many customers there are by Manager and then By Rep. Then to figure out how many were New, Current, Total # of RSVP and attended for that Rep. Below is how I have started but I am having some problems getting certain parts. I know when I get one the rest will fall into place. I can calculate how many total customers by manager and by rep just by doing a Countif command but how do I determine the # of New, Current etc. Is there a If Than command? Managers Totals are simply his reps totals.
Example.. A B C D E F G 1 Manager Rep Customer New Biz Current # RSVP # Actual Attend
Need totals to look something like this....
A B C D E F G 1 # of Cust # New # Current #RSVP # Actual Attend 2 Manager 3 Rep 1 4 Rep 2
to write a code that would create a chart automatically in another worksheet when a button is clicked.
I have attached the sample data that I am working on. Each row in the sheet represent 3 coordinates, which are: coordinate # 1 = start, 0 coordinate # 2 = centre, level coordinate # 3 = end, 0
I am working on a spreadsheet for a client. I am using Excel 2007 and she is using Excel 2000. I have created a emplate for her to enter survey data into. Using the following code, I have created combo boxes for the drop-down menus so the client can tab from one cell to the next while entering data:
Option Explicit Private Sub TempCombo_KeyDown(ByVal _ KeyCode As MSForms.ReturnInteger, _ ByVal Shift As Integer) 'Hide combo box and move to next cell on Enter and Tab Select Case KeyCode Case 9 ActiveCell.Offset(0, 1).Activate Case 13 ActiveCell.Offset(1, 0).Activate Case Else 'do nothing End Select End Sub.....................
I am aware of the Visio capabilities of importing data into the org chart wizard to create an organization chart. Is there a similar capability in Excel only? I know there are smart art org diagrams, but if I have a spreadsheet of several hundred people, is there a way to import it into a chart (again, similar to the Visio process).
I am trying to write a simple macro to create a chart over the used range in a worksheet. The first part of the macro correctly selects the used range which in this case is A1 to F19 when I single step through the macro. A listing of the macro is shown below:
Code:
Sub AddChartObject() ' Sheets("Sheet1").Activate Range("A1").Select Range(Selection, Selection.End(xlDown)).Select Range(Selection, Selection.End(xlToRight)).Select
[Code]...
When I place the formula given in MyArea as an argument for the source data, I receive a syntax error, so obviously it is the wrong argument. Numerous attempts to correct it also failed. As a sanity check, I placed the used range in an argument for the source data and was able to create the expected chart. fix the syntax error in the macro
I am trying to create a bar chart that changes color based on a percentage range. Any advice on how to do this? I am using Excel 2007, Windows XP, Sharepoint 2010.
I have 6 columns. The 5th and 6th columns are the most important. The 5th contains a figure and the 6th contains a type.
Bascially I am trying to do a basic chart showing the following 2 things. A. Do a percentage chart of column 6 (service) but not of percentage of hoem many lines the product is in. Not based on percentage of how many times Apples are shown compared to other products. I need it to add up everything, then do a percentage of total amounts of oranges and total of for Apples from the figures on column 5. Also, if possible, the pie chart will even show teh actual total figure per product in each (or next to) each pie chart slice.
know the easiest way to do this (step by step) in Excel 2010 and then I can perhaps write a macro for the future?
I have a data set where the rows contain monthly sales data (from January to December) and the columns contain the names of employees (joe, bob, sue, etc.) and a single "group average" column:
I would like to create a chart for each employee showing the employee's monthly sales vs. group average. For example, the first chart would be for joe...
Then the next chart will be for bob and so forth...
I've got a worksheet_selectionchange macro on a sheet, and another macro that you can run after it. The issue is that when the second macro runs, it also runs the selectionchange macro, and wipes some of the info that the second macro should be copying.
Is there a piece of code that I can use in the second macro to block the selectionchance code from running until it's compelte?
Trying to create a macro to run through the following steps when I select a chart and run the macro:
Paste>As Picture>Copy As Picture>As Shown When Printed>OK
I used the macro record feature and when I enter the shortcut it always returns the same chart. How do I get it to run on whatever chart I have selected instead?
I am constantly using this function to copy charts from Excel into PowerPoint presentations and am frustrated with all the extra steps it takes (versus just Ctrl-C).
I have a leave history report with data for leave taken for the 2014 year. The sheet contains the following headings:
Name; Leave Start Date; Leave End Date; Date Paid; Days Taken; Roundup; Offset
The roundup column rounds the days taken up, for example if someone took 0.4 days off it would round it to 1.The offset column just subtracts the Roundup value by 1 (=Roundup-1) I think we will need this for what I am trying to do.
I have created a new spreadsheet labelled gaant chart, this shows the name of the employee with the working dates for the year and has the following data:
Name 1/01/2014 2/01/2014 3/01/2014 6/01/2014 7/01/2014 8/01/2014 9/01/2014 10/01/2014
[code].....
What I would like for the macro to do is lookup Employee 1 from my gaant chart table and search the leave history data if it finds a relevant start date for the employee it marks that date with a 1, it then looks in the offset column and marks the number of offsets to the right. For example if employee 2 took leave from 1/1/14 to 3/1/14 the macro would mark a 1 on the 1/1/14, and search the offset column which would have 2, it will then mark a 1 in the 2 cells to the right of 1/1/14 also (these being 2/1/14 and 3/1/14)
I have been trying to create a macro in excel to chart a selection of data and to output the chart on the active sheet where the data was taken (as opposed to a named sheet). So basically, I have about 300 worksheets with data, and I would like to have a button on each page that automatically charts that data when clicked, and outputs the chart to the page where the macro was clicked. However, I have not been able to figure out a relative reference that will allow me to make the LocationasObject reference simply the ActiveSheet as opposed to a specifically named sheet. See my code below, which references an output to a worksheet called "Charts". Right now, all of my charts are outputting to the sheet called "Charts", as opposed to the active sheet.
Sub ConsDiscChart() ActiveCell.Offset(29, 11).Range("A1").Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlToLeft).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlUp).Select Selection.End(xlDown).Select ActiveCell.Offset(0, 1).Range("A1:B1").Select Range(Selection, Selection.End(xlDown)).Select ActiveCell.Offset(0, -1).Range("A1:C24").Select Charts.Add ActiveChart.ChartType = xlLineMarkers ActiveChart.Location Where:=xlLocationAsObject, Name:="Charts" With ActiveChart .HasTitle = False .Axes(xlCategory, xlPrimary).HasTitle = False .Axes(xlValue, xlPrimary).HasTitle = False End With End Sub
can i use a combo box with a dropbuttonclick to run the macro only when the arrow is selected . The problem I am having is the macro will run on the selection of the arrow which is whatt I want but it also run when I make a selection it the combo box
I'm trying to add buttons to an excel spreadsheet at runtime. Each row in the spreadsheet should have its own buttons. I was able to create and edit them with the ActiveSheet. OLEObjects.Add() function, but after that, when i was trying to create code dynamically to react on the buttons' click events excel crashes (actually it works for one button, but not if my routine for adding a new button and event code is called more than once in a row!)
The code below works if the AddCmdbuttonWithCode() is called once, but crashes if it is called two or more times. Excel tries to restore the document after the crash and the first button and its corresponding click event code is visible and works... but NOT the second button and its event code...
The only way I can create multiple buttons right now is by calling my method once per click, opening the vba editor, changing the parameters for my AddCmdbuttonWithCode() routine and execute it again. After that I have mutliple buttons in different lines which all work fine (so the concept seems to work).
The problem seems to be the insertLine method, since everything seems to work if i leave it out (except for the code generation of course, since this is done by this part of the code :-) ). Is it possible that calling the insertLine Method can't be called multiple times? I don't know... any ideas? Feel free to test my code - it's small, easy to understand and has comments.
'this code calls the method which creates the buttons in specific cells with specific names Private Sub CommandButton3_Click() 'the first call always works! AddCmdbuttonWithCode "Edit_111_111_114", 23
'the second one crashes excel AddCmdbuttonWithCode "Edit_111_111_115", 27 End Sub
I have a program that updates values quarterly when run. The spreadsheet that it works with also contains a couple of pie charts that correspond to the updated data. the charts only have one series with category values. I recorded a macro to see the code excel uses for creating a new chart and tried to modify the statements to my needs but have been running into runtime error 1004 ("Method ' Cells' of Object '_Global' failed"). The code is as follows I don't have any trouble until the last two statements.
Sub Chart_Updater() Sheets(Chart1var).Select With ActiveChart .HasTitle = True If Chart1var = "COLI VUL 1 Fund Chart" Then .ChartTitle.Text = "COLI VUL 1 Allocation by Fund Provider " _ & sday & "-" & sday & "-" & Lyear ElseIf Chart1var = "COLI VUL 2 Fund Chart" Then .ChartTitle.Text = "COLI VUL 2 Allocation by Fund Provider " _ & sday & "-" & sday & "-" & Lyear ElseIf Chart1var = "COLI VUL 7 Fund Chart" Then .ChartTitle.Text = "COLI VUL 7 Allocation by Fund Provider " _
The variables fundtr1, fundtr2, and emptycolvar are public, and are all returning values, so there is no problem there. Also I can't use ranges like "A1:F7" because the range needs to be variable.
I have a spreadsheet (see attached) in which there are many series and i want to be able to delete most of the series except the first 4.
(The 0%, 5% 10% air voids and the 95% comp line)
iv got this code, which is attacted to a command button, which works fine to delete all the series but makes the graph a blank white box. id prefer it so it delete just the series not the graph "picture?" ...
I have managed to create something similar to what i am working for using an example from Lacher and Gant Charts. i am now stuck as I can enter more than 40 status as it then gives me an error. The following is the code: Can any1 highlight where i need to make any changes to stop the error from occuring:
Option Explicit Sub CreateTimeChartData() Dim vTimeData As Variant Dim i As Integer Dim sRoom As String Dim vLastEndTime As Variant Dim oSeries As Series ' set up Application. ScreenUpdating = False Application.DisplayAlerts = False ' create chart data worksheet With Worksheets("TimeData"). Range("TimeList"). CurrentRegion .Sort Key1:="Room", Key2:="Start Time", Header:=xlYes vTimeData = .Value Worksheets.Add On Error Resume Next Worksheets("ChartData").Delete..........................
I have about 50 lincharts that I wont to update with VBA but they have different number of series. Some have two series, some three and others four. Is there a way to count how many series a chart has? Otherwise could I get tips on how to approach this problem.
Right now I use a VBA-Code to create new worksheets in a workbook. my Question: is it possible to attach code to the newly created Worksheet via vba-code??
Is there a way to label individual points on an excel surface chart? (e.g., naming individual peaks on a hilly terrain, but not labelling any other points)