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????
What is the most efficient VBA code for the following macro recorded codes? I wish to write more efficient code versus the lengthy, cumbersome macro recorder code.
1) Macro Recorder Code to Copy One Sheet to Another
I hide all Excel standard tabs and thus need a button on custom tab to record a macro. (I did this successfully with custom menu in Excel 2003.) In 2007 ribbon, I've reused the code for a button's OnAction, now going to callback that runs:
In Excel 2003, the stop button appeared automatically for me. But in Excel 2007, with hiding standard tabs, etc., I see no way to stop recording, other than running my button to return the Developer's tab, where the Record Macro button has changed to Stop Macro.
I'd like to either add a second button to my ribbon to stop recording the macro (but I can't find an idMso to use in a callback) or have my Record button change to Stop button, like Excel does. But I can't come up with correct code.
I used macro recorder, and this code was the result. Is there a way to shorten this code up? The more I use macro recorder, the more I'm beginning to realize that the code generated from macro recorder can be very sloppy.
Is it possible to use the Macro recorder in Excel to store user variables that they put in through a UserForm? So say when a textbox on a userform is changed, it records a macro of what is put into the textbox, which it can then call to retrieve the value.
I've created VBA code in Access 2007 to create a column chart in Excel, and it is working. I need to change the rotation on my category labels to 270 degrees vertical. When I record a macro on the chart in Excel 2007. I only receive the following
Sub chartingRotation() ' ' chartingRotation Macro '
' ActiveSheet.ChartObjects("Chart 1").Activate ActiveChart.Axes(xlCategory).Select ActiveSheet.ChartObjects("Chart 1").Activate End Sub
How can I get the macro recorder to record changes to chart properties?
Had 2003 now 2013. Trying to get the macro to select different printers for different doccuments. 2013 macro recorder does not record any printer info or path, all printers show the same wording just application print...
How can I get the recorder to acurrately record and diferentiate printers?
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"
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
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?
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
I have recorded a macro that will copy and paste information from text files to two separate sheets in a workbook. Previous versions of this have worked fine but now I have a "subscript out of range problem" for this line: Sheets("Raakadata").Select
I'm doing this project to someone else and the weird thing is I don't see this error in my computer but they have it in theirs. The workbook has been recently renamed to oljy_vedesta.xls but it should be correct in the code. The syntax should be fine as macro recorder has been used but still this error comes up with the another computer (all the required files are there).
I have a macro that allows me to type numbers in cells and it auto adds to the previous value... what would be nice is if when i hit enter the cell focus stays at the current cell and doesnt move the next cell down... that way if i wanted to enter multiple values into one cell i wouldnt have to touch the arrow keys to get back to the cell
e.g: i enter a value into A1 and hit enter, instead of the box focus moving to A2, it stays at A1
Heres my current Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("DATA")) Is Nothing Then Exit Sub If Target.Cells.Count > 1 Then Exit Sub If Not IsNumeric(Target.Value) Then Exit Sub Application.EnableEvents = False Target.Value = Target.Value + oldVal Application.EnableEvents = True
Sub Delete_0_Rows() 'Assumes the list has a heading. Dim i As Integer For i = Cells(65536, 1).End(xlUp).Row To 5 Step -1 If Cells(i, 1) = "0" Then Range(Cells(i, 1), Cells(i, 1).Offset(-2, 0)).EntireRow.Delete End If Next End Sub
I have data in the first 50 rows. Then in row 51 it column A it starts 0's. I run the macro, it deletes all the rows with 0's, and it deletes row 50 also some reason. I do not understand the above macro very good to edit it, and the fact it contains 5 1's doesnt help me lol
Sub AddContextMenu() On Error Resume Next Application. CommandBars("formula bar").FindControl(msoControlButton, 0, "MYMENU").Delete On Error Goto 0 Dim objTemp As CommandBarButton With Application.CommandBars("formula bar") Set objTemp = .Controls.Add(msoControlButton, , , .Controls.Count + 1, True) With objTemp .Caption = "Formula Menu" .BeginGroup = True .OnAction = "TestMe" .Tag = "MYMENU" End With............
I was wondering if it was possible for a macro to edit a file by opening each .txt file, searching for the word "Reference", and then replace it with the word "Ref". Then save and close the text file.
So that it searches for any date and replaces with the new ones, but obviously the use of quotation marks with the wildcards makes this difficult in VBA.
How to link the cell values in with the "Replace with".
Code:
Sub findrep() Dim target, cell As Range Dim i As String Dim k As String i = "Input_Sheet!$A$2:$A$1000>=DATEVALUE("??/??/????")"
How would my macro below be edited to keep the column sizes the same as they are in the original sheet?
Sub NewUploadFile() Workbooks.Add ThisWorkbook.Worksheets(3).Range("A2:K300").Copy Range("A3").PasteSpecial Paste:=xlPasteValues Range("A3").PasteSpecial Paste:=xlPasteFormats Columns.AutoFit End Sub
how to control either the X or Y axis error bars for a scatter chart.
I'm building something like a gantt chart and I only want to use the X axis error bars and delete the Y axis bars. I've been able to add error bars by using "ActiveChart.SeriesCollection(1).HasErrorBars = True" but when i select the error bars using "ActiveChart.SeriesCollection(1).ErrorBars.Select" the Y axis (Vertical Error Bars) are automatically selected and any formatting I apply is added to the Y axis and left off of the X axis.
Does anyone know how to delete the Y axis error bars and/or choose only the X axis error bars?