I'm using the following code to open one of multiple files, copy a line from a worksheet, and then paste it back into the first worksheet, then close the opened file.
My problem is I can't get past the function to move down the rows each time it pastes. I want it to incrementally paste the values on the new row, ie. B3
, then B4
, then B5
, etc.
Sub Auto_open_change()
Dim WrkBook As Workbook
Dim StrFileName As String
Dim FileLocnStr As String
Dim LAARNmeWrkbk As String
PERNmeWrkbk = ThisWorkbook.Name
FileLocnStr = "T:\Projects\data" 'ThisWorkbook.Path
Dim StrFile As String
StrFile = Dir(FileLocnStr & "\*.xls")
Do While Len(StrFile) > 0
DoStuff (FileLocnStr & "\" & StrFile)
StrFile = Dir
Loop
End Sub
Private Sub DoStuff(StrFileName)
Workbooks.Open (StrFileName)
Call Edit
Workbooks.Open (StrFileName)
ActiveWorkbook.Close
End Sub
Sub Edit()
Dim Wb1 As Workbook
Dim ws1 As Worksheet
Dim loopcal As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
lngCalc = .Calculation
End With
Set Wb1 = ActiveWorkbook
Sheets("1_3 Octave1 CH1").Select
Range("A3:AH3").Select
Selection.Copy
Windows("template.xlsm").Activate
Sheets("Data Extract").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End Sub