Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Combine Files macro

Change
If rwInput.Cells(1, 4) < "" Then

to

If rwInput.Cells(1,7) < "" Then

--
Regards,
Tom Ogilvy


"Rhonda" wrote in message
...
I have a situation where I have created a macro that
creates a backup of an excel spreadsheet for each month
with a .bak extension. I need to put together all the
data in a single table, called Master. The columns a to f
and rows 1 to 32 have the exact same info in all sheets.
This part is frozen and then there are other columns from
g to w which I scroll through which are the same for
every sheet. The macro would look in a central location
on the server for all the .bak files located here, check
in Sheet1, column g, cell by cell, to see if there is
any data there, and if so, copy the entire row into the
file called Master. The loop continues for all the rows
in a spreadsheet and then move on to another file and so
on, until done.
How can I rework this code to do that?
This is what I have:

Sub Combine_Files()
'Sub WorksheetCompilation()
Dim flName As String, Path As String
Dim Master As Range, rgInput As Range, rgOutput As Range,
rwInput As Range
Dim nRowsOutput As Integer, i As Integer
Set Master = ThisWorkbook.Worksheets(1).Range("$a$1")
nRowsOutput = 0
Path = InputBox("Enter the path to folder containing
workbooks to be compiled")
If Right(Path, 1) < "\" Then Path = Path & "\"
flName = Dir(Path & "*.bak")
If flName = "" Then Exit Sub
For i = 1 To 1000
flName = Dir
Select Case flName
Case ""
Exit For
Case "Master.bak"
Case Else
Workbooks.Open Filename:=Path & flName
With ActiveWorkbook.Worksheets("Sheet1").UsedRange
For Each rwInput In .Rows
If rwInput.Row = 1 Then
Else
If rwInput.Cells(1, 4) < "" Then
rwInput.Cells.Copy
Destination:=Master.Offset(nRowsOutput, 0)
nRowsOutput = nRowsOutput + 1
Else
End If
End If
Next rwInput
ActiveWorkbook.Close savechanges:=False
End With
End Select
Next i
End Sub




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I combine several excel files into one? Crystal Lee Excel Worksheet Functions 3 February 5th 09 10:14 AM
combine 2 files into one Calculate Date range Excel Worksheet Functions 3 November 14th 06 02:37 PM
How to combine Word97 files? User Excel Discussion (Misc queries) 1 April 26th 06 05:45 PM
Another combine two files question.... Dust Bun Excel Discussion (Misc queries) 1 August 9th 05 10:02 PM
combine two files Charles Excel Discussion (Misc queries) 1 August 9th 05 09:46 PM


All times are GMT +1. The time now is 05:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"