Apply Macro To Multiple Worksheets
Oct 11, 2007
I have a workbook in which I have 31 sheets. I've also recorded a macro that works great when I run it on one sheet, but it comes up with an error when I try to run it on grouped worksheets. I searched Google, and a few articles I saw said that in order to run a macro on grouped sheets, you have to use loops. I don't know if this is true, but I don't know how to run loops anyway, so. I want to run the macro on 30 of the 31 sheets. I was going to put the code in, but when I did that my post didn't work, so I'm thinking there might be a limit on the length of a post.
View 5 Replies
ADVERTISEMENT
Dec 2, 2009
I need to run the below code on all work sheets:
Sub Remove_Duplicate()
On Error Resume Next
Columns("a").Insert
With Range("b1", Range("b" & Rows.Count).End(xlUp)).Offset(, -1)
.Formula = "=If(CountIf(B$1:B1,B1)=1,"""",False)"
.SpecialCells(-4123, 4).EntireRow.Delete
End With
Columns("a").Delete
End Sub
Basically I have lots of worksheets and I want to remove the duplicates in column B for each work sheet with a duplicate entry...
View 9 Replies
View Related
Apr 17, 2014
I have the following macro:
[Code] .....
So right now the macro is run in every single worksheet in the workbook. Unfortunately, it appears the TRIM function erases formulas in cells. I want this macro to apply only to certain worksheets. Say the worksheets i want the macro to run on are named A1-A100.
View 5 Replies
View Related
Jan 28, 2009
Cycle through all sheets in a workbook performing the following:Store worksheet protection state (bSheetProtection)... execute code ...Restore worksheet protectionI cannot seem to locate a way to save a worksheet's protection state in a variable.
View 5 Replies
View Related
Jul 7, 2006
I am trying to loop through all of my worksheets in my workbook to apply a subotal to each of the sheets. I can get it to work with applying to just one named sheet, but I cannot get the loop to work. The sheets named "data" and "PriceList" do not need the subtotal applied.
Below is the code I am using:
Sub SubTotals()
Dim LastRow As Long
Dim wsDst As Worksheet
View 5 Replies
View Related
Sep 22, 2013
I want to create a macro to take multiple inputs from sheet 2, apply them simultaneously to the inputs on sheet 1, take sheet 1's output and list next to the inputs on sheet 2. I want to apply this to a spreadsheet with complicated calculations. Example spreadsheet attached. Related Macros I have will do a similar thing but only take one input at a time. Code as follows.
VB:
Sub x()
Dim r As Range
With Sheet2
For Each r In .Range("A2", .Range("A2").End(xlDown))
Sheet1.Range("A2") = r
r.Offset(, 2).Resize(, 3).Value = Sheet1.Range("C2:E2").Value
Next r
End With
End Sub
View 5 Replies
View Related
Aug 31, 2007
I have this macro and all I want to do is apply it to every page of my worksheet with a loop and can't find what kind of loop I need:
Sub format()
' Keyboard Shortcut: Ctrl+r
'
ActiveCell. Offset(-37, 0).Rows("1:1").EntireRow.Select
Selection.Copy
ActiveCell.Offset(37, 0).Rows("1:1").EntireRow.Select
ActiveSheet.Paste
Application.CutCopyMode = False
ActiveCell.Range("A1:K37").Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlMedium
.ColorIndex = xlAutomatic
End With
View 3 Replies
View Related
Jun 30, 2009
I have a module, which lists, by date, the number of instances of certain words as defined at the top of the column.
Anyway, this works fine - it operates on all sheets of a certain name type:
View 10 Replies
View Related
Nov 20, 2007
I recorded a macro in an Excel Workbook which contains 65 worksheets (--this is something received on a quarterly basis for which I have no control). The macro is successful within the workbook created however, a new quarter's data may or maynot have some of the referenced worksheets. 64.9 Waiv - 1 may exists and the others (2, 3, 4, etc) not. The macro fails and prompts for Debug if a worksheet does not exist.
Sheets("64.9 Waiv - 1").Select
Sheets("64.9 Waiv - 2").Select
Sheets("64.9 Waiv - 3").Select
Sheets("64.9 Waiv - 4").Select
Sheets("64.9 Waiv - 5").Select
Sheets("64.9 Waiv - 6").Select
Sheets("64.9 Waiv - 7").Select
Sheets("64.9 Waiv - 8").Select
Sheets("64.9 Waiv - 9").Select
Sheets("64.9 Waiv - 10").Select
Is it possible to alter the macro to look for and only invoke the code if a worksheet past 1 were to exist?
This is what I am requesting the macro do:
Sheets("64.9 Waiv - 1").Select
Range("B9").Select
ActiveWindow.FreezePanes = True
ActiveWindow.SmallScroll ToRight:=5
Range("J8").Select ...............
View 9 Replies
View Related
Jul 2, 2014
I have attached a test workbook excel 2010 (ignore ref# errors, I've cut the workbook down for uploading purposes) What I would like to do is have a 'Button' on my 'information Sheet' which when clicked would clear certain cells. I have searched the forum but can't find a solution, everyone seems to want to delete rows or columns but I just want to clear certain cells. The workbook will have 11 sheets each named 'caravan 1' through to 'caravan 11' The uploaded test workbook only only has 3 sheets.
On 'caravan 1' (which is slightly different to the other 10) I want to clear the content of cells
B4 & B5
C4, C22 & C41
D4 & D5
E4,E5, E22,E23,E41 &E 42
On all other 'Caravan sheets' I want to clear the contents of cells
D4 & D5
E4, E5, E22, E23, E41 & E42
It would be icing on the cake if it could give a warning such as " are you sure you want to clear these cells" but that isn't really necessary. The worksheets will be password protected, but the cells mentioned above will not be. If it proves too difficult to clear all the cells on all the sheets with one click, then perhaps a simpler solution might be to have a button on each sheet instead
View 8 Replies
View Related
Apr 2, 2012
I used VBA codes to apply different passwords for different worksheets in a single excel workbook. They worked fine. Then i applied a password to the VBA code itself through the VBA project properties. Also worked.
But my problem is that, if any one enters a wrong password to open any of the worksheets, the VBA will open an error message window and when "end" option is clicked, the VBA code will open without any prompt for the password.Thus the entire purpose is defeated.
View 9 Replies
View Related
Jun 6, 2008
I have a macro that works well for me. However, I want it to run on multiple worksheets in my workbook, but can not get it to work. Is there an easy way to accomplish this?
View 9 Replies
View Related
Sep 28, 2007
I have a excel macro that I am trying to use with multiple worksheets within the same workbook. The code runs fine on "Sheet1". However, when I click on "Sheet2", and try running the code I get an error message because the data is trying to be placed on "Sheet1".
Here is my
Sub Organics()
'The code under this section setups up the columns and rows
Range("B1:D1").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
View 3 Replies
View Related
Feb 6, 2014
I am trying to create one Excel file for accounting purposes. Within this file I want to create a worksheet for each customer I have in my store. On this sheet I want to list my costs and their payments. I would like to then create a summary sheet which adds all of the individual customer sheets together. Now this is easy to do manually, but what I need to create is an automation (Macro I assume) that does the following:
I add a new sheet and name it after the new customer. The Macro automatically adds that sheet into the formula for the summary sheet. This way may secretary only needs to activate the macro, which will copy a sheet and automatically update the summary page to include this newly copied sheet and all its information. Now the process for automating projected costs and profits is very easy and requires nothing more but to activate the macro.
View 14 Replies
View Related
Aug 12, 2013
I am not a VBA expert but I was able to find a macro which does most, but not all of what I want. I was looking for a macro which would copy data from mutliple worksheets and into single rollup worksheets. Each of the worksheets are formated the same with the same column headings. My problem is that I need the macro to copy paste values and formatting. Currently it is copying the formuals which then dont work on the rollup.
The current macro code is shown below.
Sub Combine()
Application.DisplayAlerts = False
On Error Resume Next
[Code].....
View 3 Replies
View Related
Oct 17, 2013
I have a workbook with several worksheets. Each sheet has the date in column A and column B.
Is it possible to have a macro check the last row of information in column A and column B and if it is not the date minus 1 day to fill in the dates from whatever date is last entered to the current date minus 1? Can it be done for every sheet with 1 macro or would I have to do it for each sheet?
The columns are sometimes not filled to the same row.
View 1 Replies
View Related
Dec 20, 2013
I am seeking code that will go to Sheet 4 (named "Extract"), copy a1:a5 and return to the active cell the macro was launched from and copy the values in.
The challenge I am having is how to get the code to return back to the cell it was launched from since I want the flexibility to use this macro in multiple tabs/sheets to copy the info into ANY selected cell within ANY sheet. As it is now, I have to go change the sheet name each time for the then active sheet.
I've attempted to insert a generic worksheet reference, however I end up with a debug issue.
Sub Macro10()
'
' Macro10 Macro
[Code].....
View 2 Replies
View Related
Jun 28, 2008
I am trying to apply a macro to evey worksheet. When I run it, it isn't moving on to other sheets. Instead, it starts from the beginning of the sheet i ran it on.
Sub full_Format()
Dim ws As Worksheet
For Each ws In Worksheets
Range("A1:D1").Select
Range(Selection, Selection.SpecialCells(xlLastCell)).Select
Selection.FormatConditions.Delete
Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
"=MOD(ROW(),2)=0"
Selection.FormatConditions(1).Interior.ColorIndex = 15
Dim LastRow As Long
Range("C1").Formula = "=VLOOKUP(RC[-2],'[Yahoo Industry List as of June 27, 2008.xlsx]Master Sheet'!R2C[-2]:R1048576C[1],4,FALSE)"
LastRow = Range("B1:B" & Range("B1").End(xlDown).Row).Rows.Count
Range("C1" & ":C" & LastRow).FillDown ....................................
View 9 Replies
View Related
Jun 19, 2014
I have the following code:
[Code] .....
I'm getting a Run tim error 438 object doesn't support this property or method for the If ws line. All i'm trying to do is copy the A column results starting at A5 from each worksheet listed into the active worksheet starting at A128. hiding any blank cells or cells with errors (I.e. #N/A) would be great as well.
View 4 Replies
View Related
Jul 7, 2014
for creating the macro As I dont have any idea about macro.
My question is that I just want to marge all the tab into one tab however some header in all the tab are dirffernet however I need one header.
I have attached the example file, in that tab named as "OUTPUT" that is what I needed by macro.
View 14 Replies
View Related
Aug 16, 2013
I have an Excel file that contains several worksheets. I would like to add a forumla to the next available cell. For example, if coulmn F contains the set of numbers to be sum the formula should be placed beneath the last number in column F. Each worksheet has a different length, the worksheet name will vary, and the number of worksheets will vary.
I know how to accomplish this task using the code below when the sheet name is known. Since it is not known I am unsure of the code.
Sheets("RawAmt").Select
NxtRw = Cells(Rows.Count, "C").End(xlUp).Row + 1
With Cells(NxtRw, "C")
.Formula = "=SUM(C1:C" & NxtRw - 1 & ")"
.Font.Name = "Arial"
.Font.Size = 8
.Font.Bold = True
.Borders(xlEdgeTop).LineStyle = xlContinuous
.Borders(xlEdgeTop).Weight = xlThin
.Borders(xlEdgeBottom).LineStyle = xlDouble
.Borders(xlEdgeBottom).Weight = xlThick
View 7 Replies
View Related
Apr 16, 2014
how to copy data from two different tabs and then paste it into one? My below code opens up a workbook and extracts the appropriate data, but I also need it to extract data from another tab within the workbook that was opened.
Sub LTDexportDATA()
Application.ScreenUpdating = False
Application.DisplayAlerts = False
[Code].....
View 1 Replies
View Related
Nov 17, 2006
Is it possible to create 1 macro which will execute multiple macros on different sheets?
I have approx. 12 macros that I can run in order, and I would like to create 1 button on the first sheet of the workbook to execute all 12 macros, which are contained on various other sheets. Is this possible?
When I attempted to do this, the master macro ran an odd function on my first sheet.
View 9 Replies
View Related
Mar 15, 2003
I have a spreadsheet containing a factory's operational data, with each machine in the factory being represented by its own worksheet.
The sheets all have the same structure, with each line of data representing a shift (we have 12-hour continental shifts, so column A of all the pages has the date in an standard format, and column B has either "d" or "n", representing the shift). Various datat is documented on each machine on a shift-per-shift basis.
What I need to do is figure out how to do a macro that extracts all of the lines on all of the machines' worksheets that pertain to a particular shift (for instance, all of the lines where column A read "14-Mar" and column B read "d"), and export the values of the entire row to another worksheet, creating a shift summary on one page.
To do this, I would like to make the date and shift user-definable variables that appear at the top of what would become the summary sheet, and have a button that activated such a macro at the top of the page as well.
View 9 Replies
View Related
Mar 19, 2014
I'm trying to track information pertaining to employees across different worksheets in one excel file. I have one sheet that is the master list of employees. The first column of every worksheet is the same (employees names based on their location) but track different information.
I want to be able to create a macro button that will update all the worksheets if i insert or delete an employee from the master list. When a new row is inserted, the other worksheets should be updated as well with the new name and a blank row to be filled in. And when a name is deleted, the entire row should be deleted as well.
View 2 Replies
View Related
Jul 6, 2012
I have a workbook with 4 sheets and with sheet 5 as a "consolidated" sheet. I have to create the macro, which will on a daily basis copy the populated data from those 4 sheets and paste into the sheet 5 (same workbook). The data in the Sheet 5 should be pasted from row 2 below each other.. Row 1 will be the headings and shouldn't be replaced. The data in all 4 sheets should be copied from row starting 37, columns C to BA but it will end with different row numbers. note that columns A & B are populated but shouldn't be copied.
View 7 Replies
View Related
Jun 25, 2014
I have a requirement where I need to summarize multiple work sheets. And each work sheet as different range. Column names are same in each sheet but number of rows in each are different. Like consider there are 3 sheets with employee details. Each sheet has Employee Name, Employee Number, Employee Location. But in first sheet as 10 employees and second sheet has 20 employees and third as 25. So the requirement is I need to summarize all employees.
View 1 Replies
View Related
Jul 3, 2013
I worked on a workbook which has multiple worksheets( mine has 6). The data doesn't start from A1. I want to copy the data from each worksheet into a sheet called summary. I want to create the macro that would only copy the heading row once.
WB test.xlsxWB test.xlsx
View 5 Replies
View Related
Mar 28, 2014
I inherited a price list workbook made up of multiple worksheets (some 30 pages). Each year the new prices (including % increase) are calculated by a formula in the row below each price (100's of rows and formulae).
Thus:
C1 might say £10
D1 says =C1+(C1*2.5%) £10.25 (it actually does some rounding too)
etc
It may seem odd having both rows but MD can see the before and after. The new price 10.25 must however be manually copied to C1 to avoid circular referencing and then D1 row hidden. Very laborious to repeat 100's of times.
Is there a way of first copying the entire workbook for the new year (easy) then by means of a macro looping through each formula cell of all sheets in workbook 1 and pushing the result to the new workbook and to the correct sheet and then to the same location but to the cell above. e.g. pushing £10.25 from D1 of sheet 1 workbook 1 to C1 of sheet 1 workbook 2 to become the new price for the coming year?
View 9 Replies
View Related
Apr 1, 2009
i have many file text which i want to open in an excel workbook in a way that each text file will be displayed in an excel sheet.
View 3 Replies
View Related