Macro With Reference To Active Chart On Active Sheet
May 14, 2014
I currently have the following macro running to set a chart's data values:
Sub C3Quarter12013()
'
' C3Quarter32013 Macro
'
'
ActiveSheet.ChartObjects("Chart 2").Activate
ActiveChart.PlotArea.Select
ActiveChart.SeriesCollection(1).Values = _
[Code] ......
When I copy the tab and change some of the data within the cells, I want the macro refer to the chart on the current tab and the values in the current tab - as currently it refers to only "Chart 2" and the values in the tab 'Figure 2 - WE OPH'.
I've tried changing the sheet name to ActiveSheet.name but that doesn't seem to work.
View 4 Replies
ADVERTISEMENT
Feb 21, 2009
I am trying to select cells, tables and charts by just knowing their name. Thus if possible I would like to only refer to a chart by its name i.e. not know what worksheet they are on. This seems to work for named ranges of cells/tables, but not charts (I can't get my named charts to appear in the "Define Name" dialog).
I found this code that loops through charts on the activesheet and shows the names. However, I would much prefer not to have to specify the sheet or to loop through all the sheets trying to locate the one with the named chart.
Public Sub GetEmbeddedCharts()
Dim myChart As ChartObject
Dim myCharts As ChartObjects
Set myCharts = ActiveSheet.ChartObjects
For Each myChart In myCharts
Debug.Print myChart.Chart.Name
Next
End Sub
View 4 Replies
View Related
Jan 9, 2014
I'm using a macro to paste a formulae into a destination cell on another worksheet.
The problem is that I need the Macro to put the name of the active sheet into the formulae
VB:
Sheets("Front").Select
Range("E1").Select
Selection.End(xlDown).Select
Range("E3").Select
ActiveCell.Formula=INDIRECT(ADDRESS(MATCH(9E+99+306,*****ActiveSheet.Name*****!F:F,1),6,4))
The macro has to work whis way becuse I will be using it with multiple worksheets, all with different names.
View 9 Replies
View Related
Oct 11, 2006
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
View 5 Replies
View Related
Jan 17, 2008
For example, a cell on the screen is blank. When the page is printed, the "blank cell" has printed text.
I checked "format cells" and it shows word wrap, merge cells, and left to right.
I was told to "un-merge" the cells. I did that and I still have the problem.
The color on all the cells is OK at a blue shade. When I look at print preview the cells are blank, but when the sheet is printed, the text shows.
Also, it looks like there are 2-3 cells inside the main cell.
I hope I have explained this properly, it is not easy to use the correct language to describe since I am not very good at using Excel.
View 4 Replies
View Related
Feb 20, 2009
i'm trying to delete a specific type of chart from the active sheet using this macro:
View 2 Replies
View Related
Mar 18, 2009
I have written the below macro to copy data from a sheet called "Fixit Example 1" to a sheet called "Fixit Summary Example". It works fine, but I'd like to be able to run it from any "Fixit Example XX" worksheet. As written, the data is always copied from "Fixit Example 1" regardless of what worksheet I have open.
I tried replacing Windows("Fixit Example 1.xls").Activate with Windows(Active.Worksheet).Activate but got an error "Run time error 424. Object required."
Sub MoveData()
'
' MoveData Macro
' Macro recorded 18/03/2009
View 9 Replies
View Related
Jul 30, 2009
I'm trying to create a copy of the active sheet and then rename the new copied sheet to what's in cell O4, which is a formula (see below) and then paste value cell O4 in B3 of the copied sheet. However, when I run this macro it doesn't seem to like the second line where I am renaming the sheet (run time error '1004').
"O4" =DATE(YEAR($B$3),MONTH($B$3)+1,DAY($B$3))
Sub NewMonth()
ActiveSheet.Copy Before:=Sheets(Sheets.Count)
ActiveSheet.Name = Range("O4").Value
ActiveSheet.Range("O4").Copy
ActiveSheet.Range("B3").PasteSpecial Paste:=xlPasteValues
End Sub
View 9 Replies
View Related
Jun 15, 2009
I have a workbook which has links to another excel workbook (source). This workbook has many sheets -all exact copy- with different names. I changed startup prompt (edit->links) to "dont display the alert and dont update automatic links". Then I recorded a macro for updating links (from source) and assigned this macro to a button. What I want to do is when I click this update button I want links to be updated only on the active sheet that Im on. My problem is, when I press this button, it updates all links including other sheets (basically whole workbook).
My current macro is (I dont know coding but I tried changing ActiveWorkbook to ActiveSheet but it didnt work):
Sub update()
ActiveWorkbook.UpdateLink Name:= _
"C:Documents and SettingsAlperDesktopExcelsource.xls", Type _
:=xlExcelLinks
End Sub
View 2 Replies
View Related
May 9, 2008
the macro mentioned below has been assigned to a combo-box form. I have 2 different datasets in the same sheet, they have the same headers (but named differently, myhead and myhead1) and the same adv filter criteria range (named as "dcrit") is applicable to both datasets. So, if an item is selected from the combo-box, both the datasets should get filtered according to same criteria. how i can combine the 2 IF LOOPS mentioned in the code?
Sub myfilt()
Application. ScreenUpdating = False
If ActiveSheet.FilterMode Then ActiveSheet.ShowAllData
If Not (Range("indsignal")) Or Not (Range("countsignal")) Then
Range(Range("myhead"), Range("myhead").Offset(1, 0).End(xlDown)).AdvancedFilter _
Action:=xlFilterInPlace, CriteriaRange:=Range("dcrit"), Unique:=False
End If
If Not (Range("indsignal")) Or Not (Range("countsignal")) Then
Range(Range("myhead1"), Range("myhead1").Offset(1, 0).End(xlDown)).AdvancedFilter _
Action:=xlFilterInPlace, CriteriaRange:=Range("dcrit"), Unique:=False
End If
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
View 3 Replies
View Related
May 21, 2014
How to modify the below vba code? It sends an email with an attachment right away after pressing the macro button. I would like the user to see the email in outlook before it gets send... and then press 'send' in Outlook .....
Sub Mail_ActiveSheet()
'Working in Excel 2000-2013
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim FileExtStr As String
Dim FileFormatNum As Long
[Code] .....
View 1 Replies
View Related
Dec 16, 2008
I would like to create macro, where it would on macro run copy text from active cell and find that value in another sheet (in column H) and select that cell.
What I did is this:
View 5 Replies
View Related
Feb 26, 2009
I am trying to write a macro that publishes the print area as a non-interactive web-page to a file that sits in the same location as the spreadsheet from which the macro is being run.
I am using the the following macro:
View 14 Replies
View Related
Jun 28, 2012
let's say I run a macro from a button on sheet 3, macro process on sheet 10. Is there a way that the macro would automatically go back to sheet 3? Like a "Back" button on IE. I can't code Sheets("sheet 3").Select because I want it to do the same thing on sheet 4,5,6...
View 3 Replies
View Related
Apr 15, 2014
Is it possible for a Macro to read a cell say D:11 and copy that email address and send the active sheet to that email?
View 9 Replies
View Related
Jul 14, 2009
I have a range of amounts in Sheet 1 from F7:Q13 and im using the find method to search for the active and non active values in the cell. Which means that if there's a value in the cell it will transfer the value in Sheet 2, if nothing is found in the cell the cells in Sheet 2 will return as nothing or null.
I think the problem lies on the FindWhat variable. Im getting a compiled error which im not sure what is it.
I've attached the spreadsheet so you get a better idea of the problem that i encountered.
View 13 Replies
View Related
Dec 18, 2008
I want to arrange a dataset in blocks of 8 lines and for this I need to refer to the actual row of the active cell. Below code does not work - the "Row" does not change as the active cell moves down through the rows
View 5 Replies
View Related
Feb 23, 2009
I've got 3 columns say A,B,C. Column C (row1) = Column A (row1) * Column B (row1). I'm trying to apply this formula to all the cells in Column C. I've tried typing the following formula in all of column C. =OFFSET(ActiveCell,0,-1) * OFFSET(ActiveCell,0,-2)
Obviously the ActiveCell reference doesn't work. This would be simple in VBA but here on excel how would I reference to the cell itself where the formula is contained?
View 2 Replies
View Related
Jul 4, 2007
I would like to fill data in table on another worksheet, lets call it Sheet2 that starts with the activecell from Sheet1 and then use offsets. The activecell changes, but the remaining offsets for rows and cells always remain the same. I am pretty sure , I can figure it out this out using VBA, but is there a formula way to do this? Either looking at the activecell from Sheet1 as a start or using formatting like bold the start cell?
View 8 Replies
View Related
Feb 5, 2013
I've attached a chart with variance data for each month of the year. I've used an IF formula to "NA" the months with no data, so nothing shows up in the chart. However, I would like to know if it's possible to have the chart only show months with data. The IF formula gets rid of the data point but it doesn't prevent the chart from showing the month on the X axis. In the attached file I manually selected the three months with data.
View 4 Replies
View Related
Feb 27, 2014
My company has complicated time sheets because we have several tasks that are billed differently to different people. Once a month we have to sit down and compile everything from several forms and so forth. I have created a worksheet that pulls all the numbers together so that they can simply be copied and pasted into our reports. The hope was to simply copy this worksheet into a time sheet workbook and it will pull out all of the correct numbers. Although all the time sheet workbooks are set up the same way, whenever I copy the file into another time sheet workbook the program keeps its references from the workbook it was in. Make sense? is there a formula that I can insert into an array to tell it to pull the information from the worksheet with the same name, but in the active workbook?
here is one of the equations I am working with:
{=TRANSPOSE('1st week'!A10:L48)}
so it would look something like this maybe
{=TRANSPOSE('[active workbook]1st week'!A10:L48)} but this doesn't work of course.
View 3 Replies
View Related
May 14, 2014
What I have is a sheet that is copied periodically from some source sheet, and on this sheet is a table. This sheet is called "Onsite Checklist Template" and it's table is titled "Checklist". I also have another sheet called "Loggers and Initial Notes" which has a tabled titled "Record", and then finally a title sheet call "Proj Details".
To clear this intro up - The sheets, in their order, is: "Proj Details", "Loggers and Initial Notes", "Onsite Checklist Template". The tables: "Record" on "Loggers..." and "Checklist" on "Onsite..."
When the user wants to make a new site visit, he/she fills in the requested date and then selects a button on "Proj...". When this button is selected, it copies the table data on "Record" and puts it on "Checklist", then inserts a new worksheet tab, always in the 3rd position (the title is based on the site visit date in which the user entered), which is a copy of "Onsite...". Now we have another sheet with a table called "Checklist1", and upon another new site visit, there will be another worksheet with "Checklist2", and so on.
On the "Onsite..." worksheet, there is a button on it which also gets copied with the worksheet so that every new worksheet has this copied "Checklist ???" and this button. I'm looking for a macro that, when the button is selected, will bounce the active sheet's table "Checklist ???" off of "Record" and make changes as needed.
"Checklist ???" data range is B11:M20 (the header is on row 10); "Record" data range is B29:Q78 (the header is on row 28); Column headers are titled the same, just that "Record" has 4 extra columns, 3 in the middle and 1 on the end. "Checklist ???" columns 1-12 to "Record" columns 1-7, 10-12, 14-15. The search criteria is the 4th column in both tables ("Trk #").
I need the macro to do the following:If it finds a match, then update "Record" as needed with data from "Checklist ???", changing whatever cell is different in the row that contains the matching "Trk #", so long as the cell on "Checklist ???" is populated (i.e, if a cell on the target row of "Record" has a value, but it's blank on "Checklist ???", then "Record" wins; if it's blank on "Record", but populated on "Checklist ???", the Checklist wins. If both populated but different, then Checklist wins.If a "Trk #" exists on "Checklist ???" but is not on "Record" then add the line to "Record" (the 1st empty row, table size remains)I see no need for any "delete" at this time.
My concerns: The last column on record (column #16) is the filtering column for the worksheet copy event and needs to be left alone (it's formulated to produce a "Yes" or "No")I would like the ability to adjust table sizes if needed without modifying the macroThe table rows on "Checklist ???" will not be changed, deleted, or altered in any way by the macro.
View 2 Replies
View Related
Jun 8, 2014
I have got stuck on one piece of my code and having trouble fixing... Overall I am trying to find variable station name in cell L2 of Sheet 2 in Sheet 1 and then select and copy the data from the data in "cell L2 of Sheet 2" to the last entry of that row. I have attached an example test spreadsheet of the data and a macro is within Sheet 1 called test1. Please note that cell L2 in Sheet 2 will always be different station name and the station list in Sheet 1 will change with differing station name.
The code I am using is:
[Code] .....
The code that is not working and bringing up an error is:
[Code] .....
Attached File : Copy of Testexample.xlsm
View 2 Replies
View Related
Mar 31, 2008
I would like a macro that will go to a fixed sheet, copy the format, go back to the previous sheet and paste the format. My problems arise going back to the previously activated sheet rather than just a fixed sheet.
View 2 Replies
View Related
Sep 18, 2009
I have a spreadsheet that is nearly 100 worksheets. I am new to VBA and would like to put a button on each tab to return me to the last active sheet. I've tried other codes I've found on here but with no luck. I'm not sure if i'm posting them to the right area within VBA.
View 4 Replies
View Related
Nov 22, 2011
I am not sure why this code won't delete, I can't believe excel requires the sheet to be active to delete from. It will only work if the .activate line is included.
How can you delete from another worksheet without first switching to it?
Code:
'Sheets("sheet1").Activate
Sheets("sheet1").Range(Cells(row, col), Cells(row + 7, col)).Delete shift:=xlUp
View 3 Replies
View Related
Dec 27, 2013
I'm looking for VBA code that will:
Hide a sheet whenever it is not the active sheet
View 3 Replies
View Related
Mar 22, 2007
I have this macro that looks in all sheets in column A, except the invoice sheet. How do I alter it to only check the active sheet?
Dim ws As Worksheet
For Each ws In ThisWorkbook.Sheets
If ws.Name ("Invoice") Then
On Error Resume Next
With ws
.Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Hidden = True
With .Columns("A").CurrentRegion
.Offset(2, 0).Resize(.Rows.Count - 1, 3).SpecialCells(xlCellTypeVisible).Copy _
Sheets("Invoice").Cells(Rows.Count, "A").End(xlUp)(2)
End With
.Cells.Rows.Hidden = False
End With
Err.Clear
End If
Next ws
View 9 Replies
View Related
May 29, 2008
Is there a way to create a macro to jump to the last active sheet?
For example, the last sheet I was on was Sheet1 and now I'm on Sheet20 and I want to jump back to Sheet1 without scrolling through the tabs at the bottom of the screen.
View 9 Replies
View Related
Jan 15, 2008
I have data that is laid out as follows: Date, amount1, amount2 and a value in $
There are many rows, and there will be more than one row for each date. see attached worksheet for an example.
I want to create a table that will provide me totals of the amounts and the value for each date. I have managed to do this, using subtotals, but this gets quite slow, and in any case I want to be able to reference each of the subtotals with another sheet, so I tried to use pivot tables. I managed to do the above by using three pivot tables Date/Amount1 then Date/Amount2 and finally Date/Value, and hiding the extra two date columns. However my next table of data contains 10,000 rows and over 20 columns, so I am wondering if the above can be done within one pivot table. I know very little about pivot tables, and when I try to drop a second data item in, it always puts it below the first rather than in a separate column, and I get a table looking like the one in the attached worksheet. Am I doing something very basic, wrong? Is it possible to get a single pivot table, to look like my first summary chart in the attached worksheet. If I can do it with three columns, then I should be able to extend it to my much larger table of data.
View 5 Replies
View Related