LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Looping & Dumping

My Objective: Loop through workbooks in a Folder, then point to "Proposals"
worksheet in each workbook, then dump entries into "Proposals05" worksheet in
current workbook.
The code works if
Proposals in 1st wks has "2"
Proposals in 2nd wks has "1"
Then proposals 05:
2
1

However, if:
Proposals in 1st wks has "2" and "122"
Proposals in 2nd wks has "1" and "111"
Then proposals 05:
2
1
111

instead of all 4 entries, my code below requires slight tweaking, any help
is appreciated


Sub SubGetMyData3d()
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim owb As Workbook
Dim j As Long
Dim RngToCopy, Rng2ToCopy As Range
Dim intNumRows As Integer, c As Range, lngCellTotal As Long

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\My Documents\Career")

j = 1: k = 1: l = 1
For Each objFile In objFolder.Files
If objFile.Type = "Microsoft Excel Worksheet" Then
Set owb = Workbooks.Open(Filename:=objFolder.Path _
& "\" & objFile.Name)
With owb.Worksheets("Proposals")
Set RngToCopy = .Range("B1:B" _
& .Cells(.Rows.Count, "B").End(xlUp).Row)
End With

RngToCopy.EntireRow.Copy _
Destination:=Worksheets("Proposals05").Cells(j, 1)

j = Worksheets("Proposals05") _
.Cells(Rows.Count, "A").End(xlUp).Row + 1

intNumRows = Cells(50, "B").End(xlUp).Row
End If
Next objFile

For Each c In Worksheets("Proposals05").Range("B1:B" & intNumRows)
lngCellTotal = lngCellTotal + c.Value
Next

'With Worksheets("Proposals05").Range("B" & intNumRows + 1)
' .Borders(xlEdgeLeft).Weight = xlMedium
' .Borders(xlEdgeTop).Weight = xlMedium
' .Value = lngCellTotal
'End With

End Sub

 
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
Dumping Clipboard Memory ianripping[_95_] Excel Programming 1 September 3rd 04 09:54 AM
Dumping multi demensioned array into excel ExcelMonkey[_62_] Excel Programming 2 February 3rd 04 06:45 PM
Help with dumping data Tom Ogilvy Excel Programming 0 November 14th 03 02:34 AM
Need Looping Help [email protected] Excel Programming 2 October 29th 03 08:11 PM
Dumping the contents of a VBA array to a sheet Dave[_15_] Excel Programming 6 August 9th 03 02:35 AM


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

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

About Us

"It's about Microsoft Excel"