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


Range Variant Looping Macro Many Workbooks

Nov 6, 2009

I have about 20 different workbooks and i want to create identical tables and graphs in each one of them using the least number of steps.

The number of the rows changes by workbook but the colums are identical. So the range will vary by workbook.

so for example:


name sales
a 10
b 20
c 30

name sales
a 10

So I want a macro that does the tabling and charting in workbook1 and automatically moves to workbook2 and so on.

View 9 Replies View Related

Looping Through Filtered List Is Slow

Aug 7, 2014

I am working on a sheet to check different outlets turnover, margin etc. on a certain product group or department in a certain week.

There are about 50 outlets of which the information comes to me in a raw data file with around 40.000 rows of weekly data. Each week gives qty, turnover, margin.

What I do now is to filter the raw sheet to the product group that I want the info from and then loop through the filtered rows.

View 1 Replies View Related

Looping Through Directory List To Perform Functions On Each File

Dec 3, 2009

I have a directory with over 100 .txt files. I want to open each file, parse the data and copy the data into a new file which has numerous formulas and functions to perform on the data. I have the code for doing all the work, but I have to open each file individually and run the macro. I would like to loop through all the files in the directory to perform the same fuctions. I need the looping code for getting the files from the directory.

View 4 Replies View Related

Looping Put Into A Macro

Nov 2, 2009

Aloop I am trying to put into a macro. I have a variable range of data in Column C, header is in C1. I need to split the data in each row of the array using this code.

View 2 Replies View Related

Macro Needs Looping (I Think)

Jun 17, 2008

I have a macro (written with the help of forumites here) which, when selecting a cell on a particular sheet, will select and copy data from various rows on various sheets, print a resulting chart, before returning to the original sheet.

Now, I use autofilter on the original sheet to help organise the data I wish to copy and print.

My question: is it possible to adapt my macro so that, once it has run through once, will move to the next cell in the autofiltered column and run the macro again, and again, and again... to the bottom of the autofiltered column?

At the moment, I'm running the macro, pressing the 'down' key and then running the macro again until I've exhausted the column. There must be an easier/better way.

View 9 Replies View Related

Looping In Macro

Sep 25, 2008

The below code outputs a value in the cell corresponding to alpha by drawing information from the range in issueRng. However it will only grab the value from the first cell in the range of issueRng. It grabs this cell value and outputs it in every cell corresponding to alpha. For instance if i have issueRng as the range from C6 to E6 (3 cells), then the code draws the value of C6 and puts it in the cell corresponding to alpha which for the first loop is Cell(7,6). However the code is putting the value from C6 into every cell instead of moving through the range of issueRng.

Dim alpha As Double
alpha = 6
Dim issueRng As Range
Set wb = ActiveWorkbook

With wb.Sheets("Issues")
Set issueRng = Sheets("Issues").Range(.Range("C6"), .Range("C6").End(xlToRight))
End With

For Each CELL In issueRng...............

View 9 Replies View Related

Looping My Macro

Aug 20, 2009

I am a bit stuck in looping my macro. I have a working macro that does various functions for a period (say January) and I wish to run for periods 1 to 12. The cell "A1" has a drop down list (jan09, feb09 to Dec09).

Currently I select the month from Cell A1 and run the macro. Now wish to loop this macro so it runs from Jan09 to Dec09 in one go. The cell A1 is being refererence in the Vlookup table that changes ranges in a table that are been used as dynamic ranges in a macro.

Simplied Macro Steps
1. Select month in cell A1 (sheetX), then Calculate.
2.This refeshes lookup table and runs the macro say copies cells (B10:D100) in sheetBud and pastes in sheetTest A10. Insert rows A10:A100. Ends

Currently I manually changes the step 1 and then run this macro for next month. But now wish to run it for 1 to 12 months in one go. Please please can you can help me with the Looping. Please note that the macro does other functions and the steps above are simplied.

View 9 Replies View Related

Row And Column Looping Macro

Oct 23, 2008

What I'm trying to do: While there's a value in Col A starting with A2, I need to then go to the corresponding cell in Column O, starting with O2. Then as long as there's text in the next cell in the same row keep track of those cells so that in the end I can append all text in the adjacent cells to the text in the Col O[X] cell. Then repeat as long as there's text in the next row cell of Col A. I have the routine to append the text, I just need help with the looping.


If I start with the following:

Col A Col O Col P Col Q
row 1 ----- ----- ----- -----
row 2 1 Text here new text
row 3 2 More text more text 2 more text 3
row 4 (no text in any of this row.......................................)

After running macro this would become

Col A Col O Col P Col Q
row 1 ----- ----- ----- -----
row 2 1 Text here..............................

View 5 Replies View Related

Looping A Macro, Filtering

Oct 27, 2008

I have created a macro to filter results from a set of data, paste that data to a new file, and then create charts based on that data. Right now, my macro is basically multiplied 20 times to do this for each heading. Is there a way to create a loop that will just redo the same macro but for the next data heading? Here is a sample of the first part of the macro:

View 14 Replies View Related

Ending A Looping Macro

Nov 9, 2009

I have a macro I use cleanup up excel data I paste into it. Currently I paste in data that is three columns but there is space between the different items. For example:

View 2 Replies View Related

Looping Print Macro

May 19, 2009

A macro that scans Sheet "CSD" Range "B4:B201" for the word "Yellow" and copys the data in the row based on conditions to Sheet "Yellow Ticket" and prints the Ticket.
Heres a Pic of my "CSD" Sheet.

******** ******************** ************************************************************************>Microsoft Excel - Hybels_Loading_Tickets redo for post.xls___Running: 11.0 : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutA1=ABCDEFGHIJKL1  Starting Load #         2  3800         3 Ticket ColorLoad #DropCart #Customer ALLSTARS4" Wave3-0-6 Wave6" Wave18-0-1 Wave10" HB4 Pink3851C1Hawks27  45  5Yellow3852D3Bomgaar's 28 67    6 Yellow3850E5Larry's  34  677            8           9            10            11           12            13            14            Count Sheet Esman Greenhouse's [HtmlMaker 2.42] To see the formula in the cells just click on the cells hyperlink or click the Name boxPLEASE DO NOT QUOTE THIS TABLE IMAGE ON SAME PAGE! OTHEWISE, ERROR OF JavaScript OCCUR.

Here's a pic of my "Yellow Ticket"
******** ******************** ************************************************************************>Microsoft Excel - Hybels_Loading_Tickets redo for post.xls___Running: 11.0 : OS = Windows XP (F)ile (E)dit (V)iew (I)nsert (O)ptions (T)ools (D)ata (W)indow (H)elp (A)boutA1=ABCDEFGH1R. Hls Inc.2Helping Make Your Business Grow!3        4For questions regarding product please call 800..!5For questions regarding shipping or cart removal please call 888-344.3710!6        7    Load #                                    Drop Letter                            Cart

View 14 Replies View Related

Progress Bar For Non-Looping Macro

Aug 12, 2008

I'm running a simulation that utilizes the Data Table function. The table itself is quite large (280 elements in the row, 10K in the column). It currently takes about an hour to run. (Full disclosure: I did this instead of a couple of "for" loops because I have to consolidate/manipulate a bunch of data from several sheets and it seemed to be running slower than a data table). how to write a progress bar for this type of code? I.e. code that does not loop and is just time-consuming?

View 4 Replies View Related

Looping Data Entry Macro

Sep 26, 2008

I want to use a piece of VBA to copy values from cells A1, C1, E1, and G1 and paste them into the next blank cell in an existing range called "DCopy". I am trying to use the following code, but as I have never tried writing a looping macro, have no idea what I am doing:

View 2 Replies View Related

Looping Macro: Summing Up All The Values

Sep 24, 2008

So this code works fine without any error messages but I need to add a sum feature. Any ideas on summing up all the values from the for statement into the cell that corresponds to the value of the variable t. I think i need to store the the value of the for statement as a variable and then at the end of the for statement add the next value from the for statement and so on

Dim t As Integer
Dim m As Integer
t = 7
m = 11
Do While Cells(t, 7) ""

For m = 11 To (30)
col = Split(Columns(m).Address(0, 0), ":")(1)
Cells(t, 8).Formula = "=VLOOKUP(G" & t & ",indirect(" & col & 2 & "),2,FALSE)"
m = m + 1
Next m
t = t + 1

View 9 Replies View Related

Looping Macro Contional Formatting

Dec 29, 2008

Sub highlight()
Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLessEqual, _
With Selection.FormatConditions(1).Interior
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
End With
Selection.FormatConditions(1).StopIfTrue = True
End Sub

the only thing is i can't get it to do it for the hole spreadsheet!

i could copy it on to each line! I have 105 .lines and it needs to be compared to a number that is on that line!

I have tried to use some
i = 1 to 105 ---- but i don't know what that means, where to put it or how to use it

just so you know the basic of why i'm asking this is
i work for a small tv station, as most media it has ratings.. I have to highlight the 15 minute blocks of time that we rank higher in!
so for example!

US - time frame - rating Them - rating
1st 15 minutes .05 1st 15 minutes .02
2nd 15 minutes .03 2nd 15 minutes .09

but i have like 8 other stations and a full 24 hour period i normally highlight

View 9 Replies View Related

Looping A Macro To Build A Report

Jul 14, 2009

I have a very large workbook which includes 100 sheets (A) each containing fixed data relevant to one unit (n) (in this case n = a building; there are 100 buildings), a few sheets (B) containing parameters & settings, and then 1 main sheet (C) which does complex calculations pulling & combining data from sheets (A) based on the parameters in sheets (B). The workbook is so large, (100MB+) that it has to be set to calculate manually.

One of the settings in one of the sheets (B) dictates which building (n) is currently being looked at. As such, sheet (C) effectively builds a report for building (n) and so can report on just one building at a time, that building (n) being determined by a drop-down box listing all of the available buildings and that list is in turn defined in one of the sheets (B).

If I want to get a consolidated picture for all buildings I currently manually change the building choice (n) in the dropdown box, and then run a macro (m1) which updates the report to show what I want, selects the specific bits of the report I want and copies the selection, switches to a separate pre-formatted consolidation sheet I have created (D), jumps to the last row in that sheet, pastes values and then jumps back to Sheet (C).

I then need to manually change the selection (n) and then rerun macro (m1).

What I would like is another macro (m2), which automatically loops through the different values for (n) so that the whole process is automated. Then in a perfect world, perhaps even a separate macro (m3) which would give me a list of tickboxes so that I could select specific properties for which to run the report.

View 9 Replies View Related

Looping Through Each Worksheet And Calling A Macro

Jan 13, 2010

I had create a few macro with the macro name the same as the worksheet name.

How can i create another macro to loop through all the worksheet and if there is any data in Cell A1, it will call the corresponding macro. If there is no data, it will go onto another worksheet.

View 9 Replies View Related

Looping Macro With Multiple Criteria

Aug 17, 2006

I would like to write a macro that would accomplish the following:

Check (b2..b65k) <> 6710 or 6720
ActiveCell "6400"


In words. I would like to check for each type account numbers in the cell to the right, if neither occur, then in the activecell write 6400.

View 4 Replies View Related

Macro Not Looping To Correct Position

Sep 19, 2006

I'm having trouble with a macro not looping back to the right place. The macro runs fine but is looping back to the very beginning instead of to the DO WHILE point which is the bit I would like to loop through. The code I have posted is a little long I am afraid (with the first part being largely irrelevant to the issue I am trying to solve), but I have marked where I am trying to get the macro to loop though.

Sub Collect_Trade_Data()

Dim y As String

Dim strResult As String
strResult = Dir("K:BTSFilesMQ_FromBloombergutilities.txt")
Select Case strResult
Case ""

Case Else

Application. ScreenUpdating = False

Workbooks.OpenText Filename:="K:BTSFilesMQ_FromBloombergutilities.txt", _
Origin:=xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False, _ ...............................

View 9 Replies View Related

Macro Keeps Looping Without Coming To The End Of The Last Worksheet

Jan 19, 2007

This macro works when there are only a small number of worksheets in a workbook. But as soon as it increases to say 20 or above worksheets, the macro keeps looping without coming to the end of the last worksheet.

Sub LDK_Print_Orientation_New()

Dim intOr As Integer
Dim wkscount As Integer

wkscount = ActiveWorkbook.Worksheets.Count
For x = 1 To wkscount

Application. ScreenUpdating = False 'Switches off screen updating and calculations

x = MsgBox("Print in Portrait", vbYesNo, "Printing Choice")............

View 9 Replies View Related

Looping Macro To Populate Master Spreadsheet?

Feb 11, 2013

I have a number of spreadsheets, all of the same format, saved into ("C:Email Attachments").

I wish to populate a master workbook, using a macro to loop through all of the workbooks in that folder, copying all of the data (Starting at B52-Q52) using Selection.End.Down, as the row count is always different and pasting it into the master workbook. Sometimes there may only be one row, so an IF statement may be required, to say if there is nothing in B53 then don't do Selection.End.Down. The overall result would be for all of the data from each spreadsheet is detailed as one big list in the master spreadsheet.

View 4 Replies View Related

Looping Macro (delete Every Other Line On A Spreadsheet)

Jan 16, 2010

How do I write a macro that will delete every other line on a spreadsheet? I can create a macro that delete one line using the Record a macro command but what do I ad at the end of the macro to keep it going until stopped with Ctrl Break?

View 13 Replies View Related

Looping Macro Generating Unwanted Results.

Jan 27, 2009

I have a spreadsheet with multiple departments on it set out in no particular order, (just as they are added) and this sheet needs to stay like that as a record of when added.

The problem I am having is that I need to generate a bordered blank Weekly, Monthly or 52 week planner for what ever department needs it on a different sheet so it may be printed. This will contain that departments items but leave the days/weeks blank for them to fill out.

As an example I use the code below to loop through the original sheet and generate a 52 Week Planner if the criteia matches.

View 3 Replies View Related

Looping Macro To Reformat Data From One Sheet To Another

Mar 17, 2009

I'm using Excel 2003, version 11 and am trying to reformat data from one sheet to another. What I would like to do is copy the rows for each team from the Input sheet (Input tab) and and use them to build rows on the Output sheet (Output tab) for each possible combination of players.

In my attached example, a three person team has three combinations and a five player team has ten combinations and so on. I know this is probably a loop within a loop but I can't seem to get the right combination. Not all teams are full yet so the number of players on a team will vary. I need macro code to make the input sheet look the output sheet.

View 3 Replies View Related

Looping Macro, Number Increases - 2007

Aug 26, 2009

The following is the macro I have created, but I can't get it to loop. I need to insert a row below Labour-Overtime about 100 times in the document, not just once. Until the bottom. Also, active cell 1013 needs to be the same as what is above it. The series repeats and goes up by 1 every time. Not sure how to get that to work.

View 5 Replies View Related

Looping Macro On Find Closest Match

Jun 19, 2014

I have modified some code I found in these forums that once I enter a value in a cell I can have it find the closest match to that value and scroll down the list and paste that value as an offset. The code works perfectly, but my data will often contain the same values repeated and these aren't duplicates and I need to know how to loop the code to ensure it doesn't just find the first value but also the second (if the first is already populated) Code is:

Sub findclose()
Dim rng As Range, Dn As Range, Mx As Single, oAd As String
Dim num As Range

Set num = ActiveSheet.Range("B1")

[Code] .......

---- What I need to do is insert a loop of some sort that basically says IF my offset cell has a value then to find the next closest amount and continue the macro.

So if my list was:


And I wanted to find 499 then my list would look like:

500 499

BUT if I wanted to match off another amount of 501 it would keep the 499 it found and then find the 501 making the completed list look like:

500 499
500 501

Right now the amounts are being overidden as I don't know how to loop it...

View 6 Replies View Related

Looping Macro (copy And Paste It To The End Of Row, And Make It Value)

Feb 27, 2010

I've tried to record macro, placed formula in row 4 only, copy and paste it to the end of row, and make it value. My database begin form column AM to BG.

' Macro recorded 2/22/2010 by FAUZAN

View 9 Replies View Related

Variable File Name And Looping Macro To Insert Formula?

Jun 13, 2014

I would like to create a change event macro that will update multiple formulas that pull data from various tabs on a file. The tabs are named with a single date. So ideally when a certain master cell (Allocation!H2) is updated to the current date the macro will be prompted to update the range that contains formulas and update accordingly...so its and index match fomula based that has a variable being the tab name which is a date. I have a range of dates in cells F4:AB4 and want the formula to go into F5:AB5, I can then fill that down to whatever row I want...that bit I can handle.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCells As Range
Set KeyCells = Worksheets("Allocation").Range("H2")


View 4 Replies View Related

Looping Macro Based On Range On Cells On Worksheet

Mar 8, 2007

Sub New_Book()
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=R[-2]"
Dim ThisFile As String
Const MyDir As String = "C:"
With ThisWorkbook
ThisFile = .Worksheets("2006-07").Range("b3").Value
. SaveAs Filename:=MyDir & ThisFile
End With
End Sub

The above VBA works by saving a copy of existing Workbook by refering to cell A1 and then Pasting Special worksheet 2006-07 which has external links. Is it possible to create a looping macro that refers worksheet("BUs") which list all business units I need to run and save? Range(A1) needs have a looping macro that refers worksheet BUs and then automatically saves files without manually changing cell references.

View 6 Replies View Related

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