Macro Available To All Workbooks

Nov 30, 2007

I would like to create a module for spreadsheet and I want it to be included in all excel files, i.e. whenever you open any excel file that vba module should be included

View 4 Replies


ADVERTISEMENT

Macro That Takes Workbooks Or Files And Runs Them Through Another Macro

Apr 25, 2007

i need to make a macro that takes workbooks or files and
runs them through another macro. i already have the 2nd macro
done and it is working perfectly i just need to know how to make the one
that finds the other files and runs them all through the macro i already made. My boss said that he will have about 150-200 files to run through this macro.

View 9 Replies View Related

Macro Not Working For Other Workbooks

Jan 28, 2014

Below is a code which I added to my 'Quick access toolbar' (and which is based off a hidden workbook). I use this macro to fulfill tasks to regular excel spreadsheets that are not macro enabled, however, I can't seem to get this macro to work for other workbooks. How to modify my code to work for other spreadsheets.

[Code] .....

View 4 Replies View Related

Running Macro In Different Workbooks

Mar 25, 2014

I have 7 different workbooks as part of my daily routine.

At present the first workbook is opened via the task scheduler, and the macro is run using the following code

[Code] .....

This then opens the next workbook and closes the current one. The next workbook then runs its macro again from a timed call

[Code] ...........

This repeats for 7 workbooks. The problem is, if a macro overruns - the whole schedule is out of sync when macro's are called depending on the time. What I would like to do, is link each macro by calling for the next one, and closing the current workbook. However, when i have tried to do this, the macro has always stopped when the workbook has been closed - the next macro doesn't run.

View 2 Replies View Related

Macro To Consolidate Workbooks?

Nov 13, 2013

I need to create a macro that pull in data from various spreadsheets, all with the same layouts, but with different file names and different worksheet names, into on master worksheet. The data should drop in after the title line and then continue on after each data set has copied.

View 3 Replies View Related

Macro To Work Across Many Workbooks?

Apr 17, 2007

I need to remove hyperlinks across probably 30-40 workbooks, is there a way of doing creating a macro that would do this across many instead of 1 at a time?

View 9 Replies View Related

Apply Macro To All Workbooks

Aug 10, 2008

Could somebody update the below code so that it actions all open workbooks except the master (Book2). Also, so that it appends the data (which is basically 2 neighbouring colums of data) to the Master starting in column A

Sub Format_RAW()
'
' Format_RAW Macro
'
' Keyboard Shortcut: Ctrl+s
'
Selection.AutoFilter
ActiveSheet.Range("$A$1:$P$5105").AutoFilter Field:=7, Criteria1:=Array( _
"H1", "H2", "H3", "H4"), Operator:=xlFilterValues
ActiveSheet.Range("$A$1:$P$5105").AutoFilter Field:=1, Criteria1:= _
"Tu"
Range("G7:H7").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows("Book2").Activate
ActiveSheet.Paste
End Sub

View 9 Replies View Related

Macro That Updates Other Workbooks

Sep 25, 2008

I have a macro that I use to keep other worksheets updated with current codes and whatnot. The macro opens each workbook in the directory and updates the worksheets. It works fine except that it's only updating 1 sheet within the workbook (whatever sheet is active). I need help actually cycling through ALL the sheets in the workbook. There are 7 worksheets in each workbook. The code I need help with is in red.

'=====================================================
'CODE BELOW IS USED TO UPDATE INSTRUCTIONS SHEETS.
'=====================================================
Dim FromBook As String
Dim ToBook As String
Dim ToSheet As Worksheet
Dim SPDir As String

Sub Update_Columns()

Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.Calculation = xlCalculationManual

SPDir = "m:SPDWA"
FromBook = ActiveWorkbook.Name

'-Code to loop through files in directory.
'On Error Resume Next
ToBook = Dir(SPDir & "*.xls")
While ToBook ""
If ToBook FromBook Then
Application.StatusBar = ToBook
Update_Data ' subroutine below
End If
ToBook = Dir
Wend
'-- close
Range("A1").Select
MsgBox ("Sheets Updated.")
Application.StatusBar = False
Application.Calculation = xlCalculationAutomatic

End Sub
'=====================================================
'SUBROUTINE TO LOOP THROUGH FILES AND COPY CODES.
'=====================================================
Private Sub Update_Data()
Workbooks.Open (SPDir & ToBook)
For Each ToSheet In Workbooks(ToBook).Worksheets
ActiveSheet.Unprotect "Password"
Update_Column_Fields 'Subroutine to copy codes (not shown here)
ActiveSheet.Protect "Password"
Next
Workbooks(ToBook).Close savechanges:=True
End Sub

View 9 Replies View Related

New Workbooks To Get A Worksheet_change Macro

Oct 2, 2009

Rather than just export and import a module, to import a sheet macro?

I don't quite know what they're called, but basically I have a functional Worksheet_change macro, which is sitting idly in a module. When a separate macro is run which creates new workbooks, It exports that specific module to the desktop, and then the new workbooks all import the module. THat works fine.

But I want all of the new workbooks to get a worksheet_change macro (so a macro that goes into the sheet, not into a module in the workbook)

View 9 Replies View Related

Macro On Shared Workbooks

Mar 1, 2007

I've set up a macro to run in the workbook open event, to open a user form that restricts user access to the spreadsheet. This works fine, but I need to make the spreadsheet shared and when I open it the macro doesn't run. it's still possible to use the workbook_open event on shared workbooks or if not suggest an alternative method of running the macro on opening.

View 2 Replies View Related

Running The Same Macro For Different Workbooks

May 7, 2007

I was able to create a macro that formats the worksheet that I am working on. However, I would like this macro to be available to all worksheets that I would be downloading from a system.

I tried using the personal macro workbook, but when I ran the macro, it formats the personal worksheet and not the one that I would want to format.

I used general codes, but it pasted the formulas onto the personal.xls file.

View 4 Replies View Related

Run Macro On Multiple Workbooks

Sep 5, 2007

Ive just started using vba for excel and put together a very simple peice that uses the goalseek function. See below.

Public Sub calc_vol()
Dim currentcell As Range
Worksheets("sheet1").Activate
Set currentcell = Worksheets("sheet1").Range("bl2")
Do While Not IsEmpty(currentcell)
With Application
. Iteration = True
.MaxIterations = 100
.MaxChange = 0.00000001
Application. ScreenUpdating = False
Application.Calculation = xlCalculationManual
End With
ActiveWorkbook.PrecisionAsDisplayed = False
currentcell.GoalSeek 0, currentcell.Offset(0, -13)
Set currentcell = currentcell.Offset(1, 0)
Loop
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub

The code works great (a little slow - but fine for 65,000 lines), however i have nearly 100 workbooks that i have to run this macro for. I was wondering if anyone knew how i could manipulate it so that i could incorporate all 100 files into the macro, therefore running the macro once for all 100 files. If this is not possible is it possible to link multiple worksheets.

View 2 Replies View Related

Opening Workbooks From Macro In Toolbar?

Mar 13, 2013

What I'm trying to achieve.I'm trying to create a toolbar to have visible in excel which provides me with shortcuts to a selection of functions and some other useful documents.

I've created a document "Toobar 1.xls" in column B of which I have the file locations of the documents I want to open, the documents are moved from time to time and it is easier for other users to update the spreadsheet than vb.As you can see below I've written a piece of code to open up a document, I've created a function because there are a few documents I want to create links to and thought it would be cleaner to do it like this. This code is stored in "Module1" of "Toolbar 1.xls".

I've then created a new toolbar in excel and added a custom menu item and allocated it the macro "Pension_Credit_Calc".

When I run the code from within "Toolbar1.xls" it works fine, however if I try to run it from another workbook I get "run time error 1004". I suspect it's probably something to do with where I've stored my code,

PS. The reason I have not simply created a shortcut in the quicklaunch bar is that I will also be altering the workbooks once opened.

Code.

VB:
Function OpenUp(FileLocation) As String
Workbooks.Open (FileLocation)
End Function [code]....

View 2 Replies View Related

Macro Cycle Through Open Workbooks

Mar 29, 2013

I am trying to cycle ALL open workbooks so that I can choose the file to manipulate in subsequent code this is the code that I am utilizing furhter below

this is my code

VB:

For Each wb In Workbooks
If MsgBox("Do you want to do access this Workbook for the Update " & Chr(10) & Chr(10) & wb.Name, vbYesNo) = vbYes Then
wb.Activate
VI_wb = wb.Name
I = True
End If
Next wb

But for some reason it only loops through .xls and xlm workbooks BUT not .xlsx

is there a way that I can loop through any and all open workbooks.

The reason I do this is because my update are based on many numerous excel workbooks with differnet extentions, and naming conventions and many of the come via email, I cannot use the eact naming convention

View 1 Replies View Related

Macro - 10 Workbooks Into 1 Workbook With 10 Sheets

Jan 24, 2014

I'd like to create a macro that will take 10 workbooks and add them to a new work book, but have each workbook as a separate sheet.

So every month from work I get a report file labeled as the current month (JAN_14). Then there about 19 folders in that folders labeled with product names; then in those folders are two excel files (they're all named MSTASCH_QUICKLOOK_1 and MSTASCH_QUICKLOOK). I figure if I can see the macro to combine 10 workbooks I can change it to do less or more workbooks. I had tried a macro that takes the workbooks from one file and puts them into two seperate sheets (although I would love to have the order changed of how they're put into the workbook).

VB:
Sub MergeSheets()
Dim wbDst As Workbook
Dim wbSrc As Workbook

[Code]....

View 4 Replies View Related

Running One Macro For Multiple Workbooks?

Apr 7, 2014

I have approximately 30 workbooks for which i open and run a macro to change the look and feel for client perusal.

I normally open each of the 30 workbooks and run the macro for each one.

Is there a way I can run the macro to apply to all workbooks at once?

View 3 Replies View Related

VBA Code To Run Macro In All Open Workbooks

Mar 12, 2014

I have a macro to get copy of sheet named "Doc Info" from workbook File 1 to active workbook.

I could do it for one file on any active workbook.

But what I would require is, upon executing this macro , i want this macro to get executed in all open workbooks( could be any numbers ).

I want to move copy of sheet from File 1 to all open workbooks ( which i am doing it manualy for every file )

All these open workbooks could be from any folder , wont be in same folder.

So logic is to execute my macro apply in all open workbooks in my computer.

Below is the code and i have attached file for test

HTML Code: 

Sub Copysheet()
Dim wSht As Worksheet
Dim wBk As Workbook
Dim wBk1 As Workbook

Set wBk = ActiveWorkbook 'Workbooks("File 2.xls")
Set wBk1 = Workbooks("File 1.xlsm")
Set wSht = wBk1.Sheets("Doc Info")

wSht.Copy before:=wBk.Sheets(1)

End Sub

View 2 Replies View Related

Auto Run Macro On All Workbooks/sheets

Feb 8, 2007

I have 100's of workbooks that have a mispelled word in a cell. Some of the workbooks have more than one sheet. I have written a macro that will correct the mispelling, and now would like to have the macro run automatically everytime I open a workbook, I would like for it to check all the sheets, but if not, then whatever sheet the workbook opens to will be fine. Here is the macro.

Sub mySpelling()
Dim myWord
Range("b22").Select
myWord = ActiveCell
If myWord = "Quanity" Then
ActiveCell.FormulaR1C1 = "Quantity"
End If
End Sub

I have done a search and have seen about "personal.xls", that does not seem to work. Thinking that I will have to add something to XLStart folder but not sure.

View 3 Replies View Related

Macro To Merge Open Workbooks

Oct 15, 2008

the code necessary to merge all open workbooks (each contains only one worksheet) into 1 workbook made up of all of these individual worksheets?

View 2 Replies View Related

How To Delete Multiple Workbooks Using Macro

Mar 28, 2009

I am looking for a way to close a group on Workbooks that are in separate instances of Excel.

These Workbooks get opened similar to running a Powerpoint program, but much different usage than Powerpoint.

AS AN EXAMPLE:

I have 7 Workbooks open in Excel . . . Could be more or less.

Each workbook has 2 sheets, the "User Sheet" (not the actual name, as all user sheet names vary) and a sheet named "Setup." (Always named "Setup.")

On the "Setup" sheet I have a list of all the possible Workbooks that I want to close. For reference purposes only, I'll call this list "To Close". All 7 Workbooks would be listed, but not all of them would be opened. If any particular Workbook on the "To Close" list is not open, it would simply be bypassed.

Example of list: Column A

Row 25 has the name of Workbook A
Row 26 has the name of Workbook B
Row 27 has the name of Workbook C

And this would continue down to the last Workbook possibly open. I will know how many Workbooks could possibly be open.

Other workbooks could also be open, but they would not be closed by this macro. In this example, I would only want Workbooks A & B & C closed.

I would have rows 25 thru 27 (or more) listed in the same location on the "Setup" sheet of each Workbook.

Each "User Sheet" would have a macro called "Close Group"

The macro would have to search through all open Workbooks and when it found one of the Workbooks listed for closing, it would close that workbook. Then, the macro would look for the next Workbook on the "To Close" list.

The Active Workbook would also be on the list and that also needs to be closed. I would guess that this would be the last Workbook to close, but it really would not make any difference if the macro would still work. I think the macro has to have the active Workbook open to close the others.

After the list has been gone through, the macro would stop.

NOTE: Each Workbook has it's own "To Close" list. If it would help, I can leave the Workbook Name A off of the list in Workbook A. I would do the same on Workbook B, etc. Then the Active Workbook could automatically be closed at the end of the macro.

View 14 Replies View Related

Macro To Save As Csv All Open Workbooks

Apr 14, 2009

i have this macro to save as a csv this macro only save the workbook the you are looking at, i will like for this macro to save as a csv all open workbooks preserving the name of the xls file.

Sub SAVE_AS_CSV()
Dim strFilename As String
strFilename = ActiveWorkbook.Name
strFilename = Left(strFilename, InStr(strFilename, ".")) & "csv"
ActiveWorkbook.SaveAs filename:=strFilename, FileFormat:=xlCSV
End Sub

View 2 Replies View Related

Merging Multiple Workbooks With Macro

Sep 14, 2009

I have multiple files with data in that I need to merge, basically append the data from various files to an existing file. Does anyone know of a macro that can be written to do this?

View 10 Replies View Related

Creating A Macro To Combine Workbooks?

Jul 19, 2012

I've been attempting to find a macro that would combine a number of similar workbooks into one large workbook. The files I'm dealing with are all .csv files with identical columns and headers.

I found one macro here: see below (this is the start of the macro) yet either I'm not using it correctly or there are errors in it as when I run it I get an error that says Run-time error '9' Subscript out of range and gives me the option to debug it. When I choose to debug it opens up the macro and has the following section highlighted?

Set wsMaster = ThisWorkbook.Sheets("Master") 'sheet report is built into

The macro in I found on this site begins with the following:

Option Explicit

Sub Consolidate()
'Author: Jerry Beaucaire'
'Date: 9/15/2009 (2007 compatible) (updated 4/29/2011)
'Summary: Merge files in a specific folder into one master sheet (stacked)
' Moves imported files into another folder

View 3 Replies View Related

How To Make Same Macro Run On Workbooks With Different Names

Apr 15, 2013

I tried recording a macro to automate some tasks I perform every day between two workbooks. While in one I want to go get data from the other. The problem I'm having is the name of the workbooks I want to run this on changes every time I download my data into Excel. The files always start with the same name but the date gets appended to it. Is there a way to modify the macro to just work with the two books I've got open?

View 3 Replies View Related

Macro To Merge Multiple Workbooks

Jun 3, 2013

I have been looking everywhere and I can't seem to find what I am looking for. I want to create a Macro that will go into a folder, search every Workbook (each with multiple Worksheets), and copy and paste the data onto a single Worksheet. The data that I want will begin in Row 3 of each Worksheet (the first two rows are titles and headers). The formatting will be the same for each sheet.

The only other part is that Column G has the following formula in each cell that I would like to keep if possible.

Code:
=IF(AND(ISNUMBER(F4),ISNUMBER(D4)),"Complete",IF(ISNUMBER(D4),TODAY()-E4,0))

View 1 Replies View Related

Looping A Macro Through A List Of Workbooks

Oct 3, 2007

I have a macro that will go into a workbook and copy all applications from a given date onto a master workbook. I have another workbook that has a list of around 20 workbooks and i want the macro to go into each one, and copy over the data onto the master workbook. I have the code to copy it over but i can't get it to loop thru the list of 20 workbooks.

View 9 Replies View Related

Concatinating Data From Two Workbooks (Macro)

Apr 10, 2008

I need a macro which will join information contained in two workbooks

The way I want to do this is to open a MASTER WORKBOOK (sHEET1) enter the two filenames in Cells D6 and D7 e.g Ted1.xls and Ted2.xls.

The file path would need to be entered into Cell D5 e.g s:dataspreadsheets

The filename for the concatinated sheet should be entered into Cell D8
e.g TedsConcatinated.xls (the save file path will always be as per Cell D5)

I need to open the file in D6 change to worksheet CopySheet Copy the contents of cells B2 to G48 past the contents into the mastersheet starting at cell C10

Open the file in D7 change to worksheet CopySheet Copy the contents of cells B2 to G48
past the contents into the mastersheet starting at cell C57

Save the sheet with the filename in D8

I need to do a few other things as well but this will be very good for starters.

View 9 Replies View Related

Macro To Open Passworded Workbooks

Jun 20, 2008

I've got a workbook ("Overview") which needs to refer to other workbooks (actually staff timesheets) which sit on a shared drive. All of these are passworded so only the staff member (and myself) can access them

As the workbook opens, it reads the links from the other files, and thus I have to enter the passwords one by one to update the data. I have come up with a macro which should do the job as follows:-

Private Sub Workbook_Open()

MsgBox "OK to run macro?"
' Message is here to let me know if the macro has run
Application.Workbooks.Open "S:LeaveTimesheetsFred 2008.xls", True, False, , "abc", "abc"
Application.Workbooks.Open "S:LeaveTimesheetsBill 2008.xls", True, False, , "def", "def"
Application.Workbooks.Open "S:LeaveTimesheetsTom 2008.xls", True, False, , "ghi", "ghi"
Application.Workbooks.Open "S:LeaveTimesheetsDick 2008.xls", True, False, , "jkl", "jkl"
Application.Workbooks.Open "S:LeaveTimesheetsHarry 2008.xls", True, False, , "mno", "mno"

End Sub

This seems to work, as it opens the workbooks. However, it doesn't run until after I've been manually prompted to enter the passwords. I'm guessing that the workbook links are taking precedence over the macro?

Is there either:-

a) A way to update the data into Overview without having to actually force the timesheets to open?

b) A way to make the macro run before the links update?

(btw I've not compromised the user passwords as Overview is itself passworded, so no-one can view the code!)

View 9 Replies View Related

Macro To Consolidate Various Workbooks Into Onesheet

Oct 12, 2009

I have to maintain a weekly tracker for my team. 13 team members will send me thir trackers every trackers every week and I need to consolidate all of them into 4 weekly and 1 monthly tracker. is there a macro which can facilitate this compilation of 13 excel workbooks into one new worksheet? all worksheets will be similar i.e will have same # of columns but can have different # of rows.

View 9 Replies View Related

Macro To Sum Values From Various Workbooks If They Exist

Feb 3, 2004

Im trying to come up with a Macro that will perform a =SUM() function across multiple workbooks. Some of these workbooks may exist, some may not.

For example, Summary.xls has a =sum() formula that picks up data from wbk1.xls
wbk2.xls
wbk3.xls
etc, all the way to 100

Today i only have wbk 1, 2 and 3 but i know everyday more wbk's are added so i want to create a sum type function to accomodate the sbk's that may be created at a future time.

Right now when i try it, I not only get REF/# but on opening Summary.xls I get a popup that asks me to define the missing wbk's

View 9 Replies View Related







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