Edit Chart Code To Exit If
Oct 13, 2008
I just wonder if we can have the code to exit if G2 returns an even number, as 2, 4, 6 etc?
Sub Listbox3_Change()
If ActiveSheet.Index 1 Then Exit Sub
Application.ScreenUpdating = False
With Sheets(1)
.Unprotect "mypsw"
.Range("G2").Value = ActiveSheet.ListBoxes(Application.Caller).Value
With .ChartObjects("Chart 2").Chart.Axes(xlValue)
If VBA.VarType(Sheets(1).Range("D1").Value) = VBA.vbError Then Exit Sub
If VBA.VarType(Sheets(1).Range("E1").Value) = VBA.vbError Then Exit Sub
.MinimumScale = (Sheets(1).Range("D1") - 0)..............
View 9 Replies
ADVERTISEMENT
Apr 24, 2009
I would like to call upon a function until a certain criterion is fullfilled. Then, I would like to have the result returned to me and exit (all) open functions. For value1 = 1 and value2 = 10 I expect value1*value2 = 100. Instead, the routine returnz zero. What is the logical flaw in the code below.
Function testfunction(value1, value2)
If value1 = value2 Then
'Calculating the difference
testfunction = value1 * value2
Exit Function
ElseIf value1 < value2 Then
value1 = value1 + 1
Call testfunction(matrix1, matrix2)
End If
End Function
View 9 Replies
View Related
Aug 10, 2013
I have a problem here regarding the combo box. The whole Column A has combobox. It would be easier if by just hitting the TAB or Enter it would go to the next cell just like what is usual in excel.
TAB = next cell to the right
Enter = Next cell below
View 1 Replies
View Related
Dec 12, 2008
I have a Userform with a textbox1 and a commandbutton. TextBox1 triggers a code on the exit event. CommandButton1 simply unloads the UserForm. If a user enters data in the textbox, but does not exit and instead clicks the commandbutton to unload the UserForm, the exit event code is still triggered and then for some reason the commandbutton no longer responds to being clicked. I can't seem to find a way around this.
If the commandbutton is clicked, I simply want the UserForm to be unloaded and the exit event for the textbox ignored
View 9 Replies
View Related
Jun 3, 2009
Right now i have two worksheets:
"900 - Reel"
"OverRides"
On the "900 - Reel" sheet i have a userform ("userform4") open when double clicking a specific cell. Upon opening it uses the following code to go to sheet "OverRides" to find two specific values and imputs them into "textbox1" and "textbox2" on "userform4"
View 4 Replies
View Related
Jan 5, 2007
I have a list of worksheet names in a combobox, when selected using the drop down arrow it takes you to that worksheet. The problem is say I select "ABC" from the list and it takes me to the "ABC" worksheet but when I go back to the summary page the "ABC" is already selected in the drop down box and I cannot click it any more. Is there anyway to reset the combo box so that it goes back to the first selection of the list?
Private Sub AFISGBox_Change()
Dim strSheet As String
If AFISGBox.ListIndex > -1 Then
strSheet = AFISGBox
Sheets(strSheet).Select
End If
End Sub
View 9 Replies
View Related
Jul 21, 2006
Is it possible to enable the undo command when using VBA code in a spreadsheet? Right now if someone makes a mistake it can’t be undone.
View 5 Replies
View Related
Feb 22, 2008
How do I make this formula include searching for "ann" and "john" (in separate cells)?
View 2 Replies
View Related
Jun 24, 2014
I'm working on a mac and have a macro that will go through all the sheets in my workbook and save them as PDFs to a specific location.
Sub CreatePDF()
For sh = 19 To Sheets.Count
Sheets(sh).ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"/Users/mikemahoney/Desktop/Publisher Payables/Statements/June 2014" & Sheets(sh).Name & "June 2014 Revenue Share Statement" & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Next
End Sub
The part in bold is obviously where I am saving the PDFs but it is also being included in the naming of the file. Need replacing the red text in the naming of the file with the contents of cell B9? I would still like to save the PDF to "/Users/mikemahoney/Desktop/Publisher Payables/Statements/June 2014" I just don't want the file-path to be included in the name of the file.
Also, this code seems to run into errors if a sheet is hidden, hence starting at sheet 19. Any way to tweak this code to skip over hidden sheets?
View 1 Replies
View Related
Jul 25, 2006
The way i have been creating macros is by going to the tools menu.....macro....then..... record new macro.
I have a file which I have re-formatted using a macro as described above however because i receives files every month to do updates every time i open a new file and try to perform that same macro it either wont work or it wont format the correct rows.......is VBA the solution to this????
View 9 Replies
View Related
Apr 1, 2008
I need a code to change the Macro security settings of the computer where the file is opened to enable macros.
View 9 Replies
View Related
May 28, 2013
below is the code i use to create a lotus note email.
i would like it to display my email and send it manually instead of sending out automatically.
' Open and locate current LOTUS NOTES User
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
[Code].....
View 4 Replies
View Related
Apr 20, 2007
I have some numeric data that has to be put on a log chart. but there is no option for log charts. so i converted my data to log and then drew a chart but i am unable to edit the axis intervals and starting axis value. whenever i change the value it gets back to its default value,ie 1. can anyone tell me how to draw log chart or how to edit axis intervals and starting axis value?
View 6 Replies
View Related
Jul 31, 2012
My first version is this:
Code:
ActiveSheet.ChartObjects("Chart 1").Activate
ActiveChart.SeriesCollection(1).XValues = "=DATA!$A$8:$A$19
Works without problems, but I really don't want to use "ActiveSheet" there
I changed it to:
Code:
Dim chtTR As ChartObject
Set chtTR = shtData.ChartObjects("Chart 1")
chtTR.SeriesCollection(1).XValues = "=DATA!$A$8:$A$19"
and it gives me
"Object doesn't support this property or method."
View 3 Replies
View Related
Jun 14, 2007
Creating a vba program that automatically generates charts. Looking for the easiest way to get the range of the data that the chart is using (later in program). Noticed the SetSourceData method but dont see a GetSourceData (that returns a range).
View 3 Replies
View Related
Nov 20, 2012
I have chart object in the sheet. I wrote code that makes the cart big, but it is not on top of other things. I need to add a snippet of the code that would make it "bring to the front".
View 1 Replies
View Related
Nov 30, 2012
i need to prepare a bar chart from some data. what i want to do is that i want bar size to be fixed (larger than what automatically comes) and then excel changes the size of chart based on no of x-axis values keeping the bar size fix.
(currently chart size is fixed and bar size changes accordingly, i just want the reverse that bar size is fixed and chart size changes according to no of values in axis)
View 4 Replies
View Related
Dec 11, 2006
I am trying to color code the cubes in my chart. I'd like to be able to be able to specify a specific color per cube. What code what I write for the Sheet to do this?
View 5 Replies
View Related
Dec 19, 2006
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
View 6 Replies
View Related
Jun 28, 2007
These charts are generated via a macro and have to be aligned using VBA.
The charts look fine on my screen bu their alignments and position are messed up when another person uses it on another computer.
This is the code i am using to align the charts
chartwidth = 300
chartheight = 200
With ActiveSheet.Shapes("Chart 1")
.Width = chartwidth * 2 + 10
.Height = chartheight
End With
With ActiveSheet.Shapes("Chart 2")
.Width = chartwidth
.Height = chartheight
End With
With ActiveSheet.Shapes("Chart 3")
.Width = chartwidth
.Height = chartheight
End With
ActiveSheet.Shapes("Chart 1").IncrementLeft -128.25
ActiveSheet.Shapes("Chart 1").IncrementTop -75
ActiveSheet.Shapes("Chart 2").IncrementLeft 182.25
ActiveSheet.Shapes("Chart 2").IncrementTop 139.5
ActiveSheet.Shapes("Chart 3").IncrementLeft -126.75
ActiveSheet.Shapes("Chart 3").IncrementTop 138
View 3 Replies
View Related
Aug 22, 2008
I wrote this code so that someone else can keep track of a certain bond. It will provide him with returns and a chart between 2 periods. I wrote it on Office 2007 and it works for me, from the begining I wrote the code in an office 97-2003 compatible file. The worksheet is attached.
Sub Grafico()
Dim FechaGraficoInicial As Date 'Fecha de referencia para el rango
Dim FechaGraficoFinal As Date
Workbooks("Julius Baer.xls").Activate 'Para evitar un error, NO BORRAR
Worksheets("Precios").Activate
Columns("G:G").Select
Selection.ClearContents
Workbooks("Julius Baer.xls").Activate
Worksheets("Rentabilidades").Activate
FechaGraficoInicial = Worksheets("Rentabilidades").Range("B22")
FechaGraficoFinal = Worksheets("Rentabilidades").Range("B23")
i = 0
Condicional = 0 'Determina si el grafico se hace o no..........................
View 2 Replies
View Related
Sep 2, 2006
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.
View 5 Replies
View Related
Jul 16, 2007
I am in the middle of building a macro for some data to be automated. I have two sheets, one of which has an existing chart but the data has been removed so now there is no values on the chart. I then have a second sheet with data on it. The range is b4:c16. I want to point this data onto my chart on the other sheet.
View 2 Replies
View Related
Dec 21, 2007
How do I write a short piece of code that defines the specific height and width that I want to assign to an existing chart. The code will be added to existing code that I have that formats the chart in other ways. This needs to be able to work with any active chart selected, not a specific named chart.
View 2 Replies
View Related
Mar 21, 2008
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#
View 5 Replies
View Related
May 27, 2008
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?" ...
View 7 Replies
View Related
Jun 17, 2008
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..........................
View 3 Replies
View Related
May 8, 2009
very complex spreadsheet for weight & balance calculations. It's to the point where everything works perfectly in Excel 2007, but it must be used primarily with Excel 2003. Discovered that a crashing problem had to do with condtional formatting, that's all been cleared and will soon be fixed, but there's one that I just can't quite figure out.
I'm using the worksheet change event to trigger the update of charts... In this case, it's looking at a particular cell that has data validation on a dropdown as the trigger. Works perfectly in 2007, and if I put a msgbox prompt in to be launched by a change of that cell, it launches. I can put the chart update code in a separate sub and launch it manually every time, but I cannot call it from the worksheet change.
I've included attachments showing what I believe are the relevant bits of code -
View 9 Replies
View Related
Apr 27, 2008
In VBA, how to add a secondary x-axis in the lower portion of the chart if I already have the primary axis in the upper part?
This code
ActiveChart.HasAxis(xlCategory, xlSecondary) = True
just adds it to the upper if I have the primary at lower.
View 4 Replies
View Related
Jul 1, 2008
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.
View 2 Replies
View Related