Hello. I am going to use the following pieces of code for a project. Can someone help me combine them? They are different steps of a project but I don't know how to create just one set of code. Thanks.
Sub OpenFiles()
Dim MyFolder As String
Dim MyFile As String
MyFolder = "C:\Users\amartino\Desktop\jim"
MyFile = Dir(MyFolder & "\*.xls")
Do While MyFile <> ""
Workbooks.Open Filename:=MyFolder & "\" & MyFile
MyFile = Dir
Loop
End Sub
Sub WBLoop()
Dim wbk As Workbook
Dim wb1 As Workbook
Set wb1 = ThisWorkbook
For Each wbk In Workbooks
If wbk.Name <> ThisWorkbook.Name And wbk.Name <> "Personal.xls" Then
wb1.Sheets("Sheet1").Range("A1:C5").Copy wbk.Sheets("Sheet1").Range("A1")
End If
Next wbk
End Sub
Sub copyOpenWB()
Dim wb As Workbook
Dim wbs As Workbooks
Dim shM As Worksheet
Dim i As Long
Dim stDate, stHeader As String
Dim dDate As Date
Dim rng As Range
Set shM = ThisWorkbook.Sheets("Sheet1")
Set wbs = Application.Workbooks
i = 1
stFile = ThisWorkbook.Name
For Each wb In wbs
wb.Activate
If wb.Name = ThisWorkbook.Name Then
GoTo PassWB
Else
stDate = wb.Sheets("Sheet1").Range("A3")
stDate = Trim(Right(stDate, Len(stDate) - 5)) 'remove Date:
dDate = CDate(stDate)
stHeader = WeekdayName(Weekday(dDate, 1), True, 1) & " " & Format(dDate, "Mmm dd")
shM.Cells(11, i) = stHeader
With wb
For Each rng In Range("R7:R36").Cells
shM.Cells((rng.Row + 6), i).Value = rng.Value
Next rng
End With
End If
i = i + 1
PassWB:
Next wb
End Sub
Bookmarks