Run Same Macro On Multiple Sheets?

Sep 8, 2012

I have a macro and I want to run that macro on multiple sheets. I don't know how to select multiple sheets. I have selected for example three worksheets.

I have used the following code but the code runs only on sheet 10. what do I need to do to make it work on all the sheets ?

Code:
Sub multiplemacro()
Dim wsh As Worksheet
Sheets(Array("Sheet10", "Sheet11", "Sheet12")).Select

[Code].....

View 3 Replies


ADVERTISEMENT

Excel 2010 :: Macro To Save Multiple Sheets To Multiple PDF With Cell Value As Filename

May 6, 2014

I would like a macro to be able to save 26 tabs within the one document to individual PDFs.Preferably I would like to be able to specify each time exactly which tabs get printed, because often I don't need to print all 26, just the first 10 or so.I would like each PDF to automatically be named with the value in cell E10 of each tab.E10 already has a formula to create its final value. It references cells from other tabs within the same document. Hopefully the fact that this cell has a formula in it won't affect my ability to use the resulting value as a 'save as' reference?I would like it if the PDFs save to the same location as the Excel sheet from which they're generated is located. The location of the excel sheet will change every three months, so I'd prefer not to specify a location with a specific filepath, as it will have changed by the time I run the macro again.

I am using Excel 2010.

View 5 Replies View Related

Run VB Macro On Multiple Sheets

Apr 17, 2009

Hi i have this macro below which works perfectly to clear the contents of column A. I will have multiple worksheets all named from 1,2,3,4,5 upto 50.

What i would like to do is modify this script below so it will run on the worksheets labelled above.

View 7 Replies View Related

Macro To Get Min / Max/ Avg Values From Multiple Sheets

Jun 27, 2014

I have multiple sheets and a summary sheet in the beginning. and i need to populate the min value / max value and the avg value for every sheet into the summary sheet.

Example i have a column of numbers in column G and i need the min , max and round(avg) for all sheets in the first summary sheet.

View 2 Replies View Related

Macro For Data In Multiple Sheets?

Mar 21, 2014

I want to consolidate the various employees' salaries of all months in a sheet. I enter salaries in different sheets month-wise and in each sheet, department-wise. Some employees get commission in various departments. Now, I need to see the details of an employee by giving his name. I should get month-wise his salary, commission and department in which he get commission, across all the sheets.

View 1 Replies View Related

Macro For Printing Multiple Sheets

Mar 13, 2008

Print sheet 1, 3 and 7. Always print sheet 1, however only print sheet 3 and 7 if there in these sheets are values in the cells from row 8 and below.

(If that is to complicated it would be ok if the condition for printing sheet 3 and 7 is that there's a value in e.g. cell A8.)

I managed to create this script that allows me to print sheets 1, 3 and 7, however I can't seem to find out where to put the if-statement (I suppose that's how you do it?). Here's the script i created so far:

View 9 Replies View Related

Macro To Combine Multiple Sheets Into One

Jun 29, 2011

I have an excell spreadhseet that has more than 100 sheets and I would like to combine all these sheets into one master sheet (Sheet1 = MasterSheet) within this workbook. Each sheet has different number of rows used. I just want used ranges to be copied over to a master file appending the previous copied range.

Sub MergeSheets()
Dim strSheet As Object
Dim LR As Long, LC As Long
Sheets("Sheet1").Name = "MasterSheet"
LR = Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
For Each strSheet In Sheets
If strSheet.Index 1 Then

[code]....

View 5 Replies View Related

Macro With Information From Multiple Sheets?

Dec 30, 2012

I am writing a macro that organizes data, but also needs to be able to conditionally copy data from other sheets in a workbook.

I have a table with values...column A has the identifiers (strings of letters) and column N has comments related to the data in each row. So, for example, row 3 column A has the value "AAPL," and row 3 column N has the related value "sells electronic goods."

Now, I want to be able to copy column N based on the value of column A into other sheets using my macros. So, say I have another sheet in the workbook and row 6 column A has the value "AAPL," I want row 6 column N to have the related value from the previous sheet. Is it possible to do this?

View 2 Replies View Related

Using Macro For Multiple Sheets In Same Workbook?

Oct 18, 2013

I have a macro listed below that I would like to use on multiple sheets within the same workbook.

Sub PrintMacro1()
'
' PrintMacro1 Macro
' To change print format from landscape to protrait

[Code].....

View 4 Replies View Related

Macro - Hide Multiple Sheets

Mar 10, 2014

What would be the macro if i need to hide multiple select sheets? I'm working on a test with 12 sheets. Even number sheets contains the fields that they need to answer and the Odd number sheets contains the formula for score computing including the answers so it needs to be like this:

Sheet 2 - The test
Sheet 3 - Must be hidden
Sheet 4 - The test
Sheet 5- Must be hidden
Sheet 6- The test
Sheet 7 - Must be hidden

I already have the code to unhide all sheets, just need the macro to hide specific sheets like the ones above.

View 2 Replies View Related

Creating Multiple Sheets From A Macro

Dec 30, 2006

I am creating a vacation calendar for all of my associates. I have 763 employees so, i want to run a macro that will react a worksheet for each of them. I will have an employee list that will create the sheets and I will have a VLOOK Up to update and pull information when we have new hires come on board.

View 9 Replies View Related

Run A Macro In Multiple Sheets At The Same Time

Jun 13, 2007

I have to run the macro in over 75 sheets every month and they are divided in few workbooks. The workbooks have 2 summary sheets and then the sheets I need to run the macro. Can you help me to run the macro in all of these workbooks running it just once?

Sub TelcoTicketsCleaning()
'
' TelcoTicketsCleaning Macro
' Macro recorded 6/13/2007 by EQUANT
'
Dim lastrow As Long
lastrow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

For r = lastrow To 46 Step -1 'Remove rows with DSL, ISDN and PSTN services..................

View 9 Replies View Related

Run Same VBA Macro Code On Multiple Sheets

Aug 10, 2009

I am trying to run the following code on multile sheets in a workbook. so far this code is working fine for one worksheet. Can someone help me modify this so it runs on multiple sheets. There can be more then 1 worksheet in a workbook depending upon data ...

View 9 Replies View Related

Running Macro On Multiple Sheets

Jun 30, 2006

I would like to run the code below on selected sheets in my workbook:

Range("B9:AW38, AZ9:BE38, b3").ClearContents

I tried using this but it doesn't work:

Sub clear()
Sheets( Array("sheet A", "sheet B", "sheet C")).Select
Range("B9:AW38, AZ9:BE38, b3").ClearContents
End Sub

View 2 Replies View Related

Applying Macro Code In Multiple Sheets?

May 23, 2013

i have a macro code but i don't know how to apply it to all sheets in the same workbook

my code is

VB:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Intersect(Range("D5:D100"), Target) Is Nothing Then
Target.Offset(0, 1).Value = Now() [code]....

View 1 Replies View Related

Password Protect Multiple Sheets With Macro

Jul 12, 2013

I have a spreadsheet with over a hundred tabs, each of which need to be password protected (same password).

I found code on CFO.com that got me half way there. It protects all the spreadsheets, but it does not password protect the macro itself, meaning that anybody can step into the macro and unlock everything at the click of a button.

The code looks like this.

VB:
Sub ProtectAllSheets()
For Each ws In ActiveWorkbook.Worksheets
ws.Protect Password:="secret123"
Next ws
MsgBox "All Worksheets Protected"

[Code] ....

What can I do to prevent people from stepping into the macro, or prompt a password to actually use the macro itself?

View 1 Replies View Related

Macro Sort Rows In Multiple Sheets

Jan 31, 2014

Sorting.xlsx

I am trying to figure out how to make a macro that can sort some numbers from Largest to Smallest within a specific range on multiple sheets. The range is only within column D starting with cell D11: (until the data ends) on all the sheets in my workbook (the number of sheets may change with time) except for Sheets: "A", "B" and "C".

In other words I want the sort to work on all sheets except the first 3 sheets which are named Sheet A, Sheet B, and Sheet C.

I have attached a spreadsheet for an example of what I am saying.

View 5 Replies View Related

Macro To Consolidate Data From Multiple Sheets To One

Feb 11, 2014

I have the following macro, however I am struggling to make it work on my file:

[Code] .....

I have attached my sample. essentially i have the dec, jan etc month tabs to consolidate into the summary sheet. i would like the data to be dumped from both sheets into the summary sheets. i will be adding a feb, march, april etc tabs as the year progresses.

I would also like column A in the summary sheet to repeat the name of the sheet the data is being retrieved from.

Attached File : sample macro_issue01.xlsm

View 4 Replies View Related

Hide/show Multiple Sheets By Macro?

Oct 29, 2008

I got a quite huge excel file with multiple sheets. For convenience sake I want to group and hide all the sheets not necessary for the viewer.

View 14 Replies View Related

Macro - Copy Value Only From Multiple Sheets Into One Sheet

Feb 11, 2010

This Macro works fine to copy data from multiple sheets into one master sheet, but it is also copying the formula. How can I change this Macro so that it is copying and pasting VALUE only?

Sub Combine()
Dim J As Integer
On Error Resume Next
' work through sheets
For J = 4 To Sheets.Count ' from sheet 3 to last sheet
Sheets(J).Activate ' make the sheet active
Range("A10").Select
Selection.CurrentRegion.Select ' select all cells in this sheets
' select all lines except title
Selection.Offset(1, 0).Resize(Selection.Rows.Count - 1).Select
' copy cells selected in the new sheet on last line
Selection.Copy Destination:=Sheets("Combined").Range("A65536").End(xlUp)(2)
Next
End Sub

View 4 Replies View Related

Macro To Create Multiple Sheets From Template?

Nov 10, 2011

I'm trying to create a workbook with multiple worksheets. My first sheet to be named "Main" and each additional sheet to be named in sequence after the values in the cells between B5:B98 on !Main.

Example:
B5 = "01"
B6 = "01.1"
B7 = "01.2"
B8 = "02"
B9 = "03"
etc...

I'd like to have a macro that would take a worksheet in this workbook named "Template" and make a copy for each cell between B5:B98 and name that new worksheet "c" and then the value in each of those (B5:B98) cells.

Example:
First worksheet named "Main"
Second worksheet named "c01"
Third worksheet named "c01.1"
and so on.....

View 1 Replies View Related

Macro Protecting Multiple Sheets In Workbook?

Sep 6, 2012

I have a large workbook with 10+ sheets i need to protect all at once. I have created a macro in VBA below. It works, but I would like another user to be able to change formatting on the sheets while they are protected. below is my macro.

Sub ProtectAll()
Dim wSheet As Worksheet
Dim Pwd As String

[Code].....

View 1 Replies View Related

Running Simple Macro On Multiple Sheets

Oct 22, 2013

I need to run a very simple macro (filter by date, copy, and paste) on every worksheet in a workbook, and then place that data into a summary page at the "end" of the workbook. Most other posts had to do with some kind of formatting that would work in succession on the sheets linearly from left to right (for lack of a better way to put it). My problem, however, is that the data would need to be pasted into the summary worksheet, and then somehow the macro would come back to the next sheet (after the one it just did) and do it all over again, so on and so forth. The worksheets are arranged alphabetically, but other than that there is no sort of easily identifiable progression between them (i.e. Sheet1, Sheet 2, etc.).

View 9 Replies View Related

Macro To Apply Subtotals To Multiple Sheets

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

Macro: Print Ranges From Multiple Sheets

Dec 6, 2006

I am trying to write what I thought would be a simple macro to print out specific areas of my worksheets. I have shown the code below; the line causing the problem I have highlighted in RED. I am getting the following error message: "Select method of range class failed".

Reading other posts here. I think this may have something to do with the macro being assigned to a command button in one worksheet (AY114) and I am trying to get the macro to run on both the worksheet that the command button is in (AY114) as well as another worksheet (AY062).

Sub CommandButton1_Click()
Range("J2").Select
Sheets("AY114").Select
Range("A4:J53").Select
ActiveSheet.PageSetup.PrintArea = "$A$4:$J$53"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
ActiveWindow.SmallScroll Down:=45
Range("A56:M151").Select
ActiveSheet.PageSetup.PrintArea = "$A$56:$M$151"......................

View 4 Replies View Related

Macro: Insert Multiple Sheets & Name As Cell

Dec 15, 2006

I found a macro code in this forum (Macro: Insert Sheet & Name As Cell Text first empty cell it should stop, but I do not know how to do that. (for example: If cells text is: A1: DOG, B1: CAT, C1: MOUSE then macro should create worksheets named DOG, CAT and MOUSE). I would save code to macro.xls file, in that file it would be also worksheet named LIST with cells names A1: DOG, B1: CAT, C1: MOUSE... in first row. But I would like to run macro on other files, so this new worksheets would be created in that new file and not in macro.xls where where macro and LIST are saved.

Sub AddSheets()
Dim strName As String
strName = Sheets(1).Range("A1")
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = strName
End Sub

View 5 Replies View Related

Multiple Data Sheets In One Macro Model

Feb 28, 2007

I have: + three raw data sheets (needed as 3 lots of data with 25K records in each). + I also have a model that I want to take each record from each sheet, populates some cells in a seperate calculation sheet and then gets a result - which it adds to a total (array).Finally I have + a clever macro that shows me what % of the way through I am (i.e. displays the number of record processed out of the 75K (3*25K) total)

While I have got the model to work - there is some untidy code used where I start my clever % macro for x = 1 to 75K then repeat the same instructions for running the model for each section i.e. sheet 1 : 1 to 25000, then the same instructions for sheet 2, 1 to 25000 etc etc. and then end it I want to know if there is any clever coding that will let me go from one sheet to another when there is an empty cell struck on the active sheet?

View 2 Replies View Related

Macro - Copy Multiple Sheets To Master

Mar 21, 2007

Have 52 weekly spreadsheets in a workbook and would like to create a macro to copy them into a master spreadsheeet in the same workbook plus, would like the master to be continually updated with any changes that are made to the individual spreadsheets.

View 4 Replies View Related

Macro To Create Multiple Graphs From X Sheets

Aug 6, 2007

I am trying to use VB to create 50 charts each with 3 lines using data from 3 different excel spreadsheets in the same workbook. I am able to create one chart with 3 lines using data from the three spreadsheets, this is good. However I exprience problems when i try to insert a loop to create 50 charts that correspond the the rows in each spreadsheet. I am new to VB and am very inexperienced with VB. In each worksheet my data is arranged in rows. row 1 of each worksheet has the header information and rows 2 through row 50 have my corresponding data. for example A2 lists the name and F2 through T2 lists the data. I have tried a bunch of different things but nothing seems to alllow me to be able to create multiple charts which correspond to each row of data?

Sub Chart2PPT()
Dim arow As Integer
Dim acol As Integer
Dim StartPoint As Integer
Dim EndPoint As Integer
Dim rStartPoint As String
Dim rEndPoint As String
StartPoint = 2
EndPoint = 4
For arow = 2 To 5
rStartPoint = "f" & StartPoint
rEndPoint = "t" & EndPoint
Charts.Add
ActiveChart.ChartArea.Select
ActiveChart.ChartType = xlLine 'Type of graph........................

View 2 Replies View Related

Macro Button To Add / Delete Rows Across Multiple Sheets

Jul 24, 2014

I've been piecing a macro together from different sites and have run into a couple issues I can't find resolutions to. I have a excel doc for tracking paint emissions per week. I would like to have a button on my master tab that will add a row and fill the formatting from the line above across all 60 some sheets. Ideally I would like the same button to first prompt if you want to add or delete rows. When adding rows I would like it to add it above the button (there's 3 buttons and for 3 different sections) and if deleting ask which row to delete. If it can't be done in one button that's fine, I can live with that. The big thing I need is for it to replicate across all of the excel sheets. I've attached a copy of the document

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved