RoseChapman
New Member
- Joined
- Jun 12, 2018
- Messages
- 40
I would like to open all csv I have in a folder , and paste the following formula (=INDEX(A:A,1+(2*ROW()-2))) in columns E and F and drag it until the last value possible, but I do not know how to do it, please see below how far I could go. Could you please help?. Many thanks
Sub OpenFiles()
Dim MyFolder As String
Dim MyFile As String
Dim wb As Workbook
Dim ws As Worksheet
MyFolder = "C:\temp"
MyFile = Dir(MyFolder & "\*.csv")
Do While MyFile <> vbNullString
Set wb = Workbooks.Open(MyFolder & "\" & MyFile)
Set ws = wb.Sheets(1)
ws.Range("E:F").Value = "Exceldestination"
MyFile = Dir
Loop
End Sub
Sub OpenFiles()
Dim MyFolder As String
Dim MyFile As String
Dim wb As Workbook
Dim ws As Worksheet
MyFolder = "C:\temp"
MyFile = Dir(MyFolder & "\*.csv")
Do While MyFile <> vbNullString
Set wb = Workbooks.Open(MyFolder & "\" & MyFile)
Set ws = wb.Sheets(1)
ws.Range("E:F").Value = "Exceldestination"
MyFile = Dir
Loop
End Sub