I have a spreadsheet that has multiple sheets and each sheet has a graph, at oresent if i have to add a new sheet and graph i copy the last sheet, rename the tab then off we go, but i alway have to remember to also change the sheets graph title. is a mechanism so that if I change the Sheet Tab name then the chart will use the sheet tab as a chart title.
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
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.
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
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
I have a workbook with two worksheets. On the second worksheet I have placed a chart, in which several shapes (text boxes) have been added manually. With the help of a TickBox in a UserForm on the first worksheet one can hide / unhide one of those shapes (on the second worksheet). By using the Macro recorder I finally came to this code fragment:
Obviously another part of the code is used to make the shape visible again. roblem: The screen flickers. And I want to be able to do this without flickering. Searching Ozgrid revealed that the use of "Activate" makes the screen flicker. Hence, my question: How can I hide / unhide a shape (textbox) in a chart on another worksheet without of using "activate"? r: Any other way to hide / unhide a shape (textbox) in a chart on another worksheet without flicker?
I have an embedded chart with a data series and a horizontal line that changes position (y-intercept) by values entered into a textbox. To make the process more user friendly, I would like to allow the user to select this horizontal line and reposition it inside the chart with the mouse. The new y-intercept of the line should then be displayable (textbox, cell, whatever). From what I have read on Peltier's site, I will definitely need to write a new class. Classes in VBA is not something I am particularly familiar with..
I have several charts embedded in a worksheet, and I would like to use the ChartObjects Method in VBA on some of them. That requires knowing the index number of the charts I want to work with. Where/how do I get that? (For example, in the VBA Project Explorer window the only listed objects are sheets. Is there an object explorer with a chart list?)
I am having trouble renaming an active sheet from a Macro I stored in the personal.xls file. I want the active sheet to be renamed to "Data_Source" and then the rest of the code can kick in. Instead of renaming the current worksheet it creates a new one.
Why do I get the error: "Runtime error 1004: Cannot rename a sheet to the same name as another sheet, a reference object library, or a workbook referenced by Visual Basic"?
And how do I fix it? I have a macros that someone else made (thank you) and I need to make the macros create anywhere from 5-125 sheets based on the information added in sheet 1. How can I do this whe it stops me after 5 or so with the error above.
I have about 100 products and each has its own sheet that I fill with data. Once I have finished with a sheet I rename it and create a copy and then hide the original and delete the entered data from before and start over.
Is there a way I can make it so when I hide a sheet it will automatically create a copy and delete a specific range?
EXAMPLE: Complete Sheet called "Day1". When day1 is complete you click on button and it then copies itself and creates and renames new sheet to "Day2", then when "Day2" is complete you click on button and it then copies itself and creates and renames new sheet to "Day3", and so on and so forth to "Day30".
What I'm looking to do is copy sheet named January, and paste into a new sheet naming it February, then in February copy and paste into another new sheet naming it March and so (but keeping previous months). My thinking was a pop up to name the sheet to copy then another to name the sheet that it's pasted in.
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.
I run a report each month which renames the tab name called ex. "xxxxx Report 8". The 8 meaning for the month of August. I have created a macro to rename the tab, but each month when i generate the report the tab name change, hence i would have to change my macro again to reflect the tab name. What formula could i use in VBA to change the name of tab so i would not have to change my macro each month?
I currently use as shown below, which does not work since the number changes each month when i generate the report):
I am receiving a the 'Rename Sheet' dialogue box when I double left click on a tab? Normally, it will allow editing in the name of the tab, not a pop up.
I have 20 sheets in the workbook. 10 sheets are named YR1, YR2, etc. Once the user enters information on sheet "Assumptions" - names are setup and linked onto each YR page. So user enters CY10, which links to cell C5 on YR1 to show CY10.
I would like a macro that renames just the YR1, YR2, ....sheets, to CY10, CY11, .... I do not want any of the other sheets to change names.
I first insert a new sheet and then i want something (inputbox or so) where i can give in the new name of that sheet (i have to do that a lot of times, so i wont do it manually) is there any solution for this thing??
I'm trying to copy the a name from cell X2...JohnDoe and rename the current sheet with the contents of X2. I'm using the following code and getting my sheet named as "True"
Sub SheetName() ' ' SheetName Macro ' Dim ShName As String ShName = Range("X2").Select Selection.Copy Sheets.Add.Name = ShName End Sub
I have an electronic meter (Fluke AirCheck) that provides me with reports in the form of excel documents. I need to combine those documents and have a page/worksheet that contains a legend and some notes etc. for reporting to management.
Given: I have a folder with nearly identical workbooks. All contain 4 worksheets: Document map Sheet2 Sheet3 Sheet4
Goal: 1. Copy and combine, either specific sheet(s) or all the sheets from multiple workbooks into a new workbook (with prompting) 2. Rename the worksheets as the workbook file names and existing worksheet names combined.
Example: Workbook name is "101B.xls" Worksheet 1 would be = "101B - Document Map" Worksheet 2 would be = "101B - Sheet2" Worksheet 3 would be= "101B - Sheet3" Worksheet 4 would be= "101B - Sheet4"
Results thus far: Okay so I managed to find a script that does most of what I need:
[Code] .....
For renaming the worksheets I have tinkered with:
[Code] .....
But alas none of that works. I can also only copy 1 sheet at a time currently.
Another issue which seems to have reared its ugly head in the copy and paste function as the text on my new worksheets is white on white when the originals are black text on white. I can select the new worksheet and select all cells and hit "Automatic" on text and it fixes it but that's a pain on 100+ worksheets. So I need some sort of copy /paste special command, I think to make that work too.
I am trying to use ActiveSheet.Name formula to rename the active sheet. It is only working part of the time and I can't figure out why. I do know, however, when it is going to work and when it is not going to work. If cell A2 contains two words, it does not work. If cell A2 contains only one word, it does work. Here is the code. The highlighted part in blue is the code that names the sheet. I have attached sample spreadsheet if needed.
I found a post to name a sheet using the cell value with VBA but is there a "formula" in Excel that will do the same? I'm wanting only to use the first 10 letters of a cell.
I am using the following VBA to auto-name sheets in my workbook based upon what's in cell A2. However, in cell A2 I have the following formula: =B2&" - F&V Expenses". My problem is that I want the sheet to be renamed when I change what's entered into cell B2 and not necessarily what's in cell A2. Is there something I can do to my current VBA that would have it realize that the value in cell A2 really did change because I updated cell B2?
Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Range("A2")) Is Nothing Then On Error Resume Next Me.Name = Range("A2").Value If Err.Number 0 Then MsgBox "Error in Renaming" End If On Error Goto 0 End If End Sub
I have a template sheet which i want to copy in to same workbook but want it to be renamed using a name which i fill in on a seperate sheet "articles". But I only want the template copied with the new name every time i fill in a new name in the sheet "articles". Also this procedure may not overwrite existing sheets.
So there is not a predipefined table in articles but rather it grows each time I need a new copy of template.