tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I have an excel document with a macro i need help with,
all I'm trying to do is open every CSV file in the folder where my excel document is saved and do the following.
"
ActiveSheet.Range("H1") = "ISRC"
ActiveSheet.Range("H2:H" & LR1).FormulaR1C1 = "=LEFT(RC[-2],2)" "
but im stuck in a continues loop?
heres my code,
please change or just give me a better way of doing it if there is one.
thanks
Tony
I have an excel document with a macro i need help with,
all I'm trying to do is open every CSV file in the folder where my excel document is saved and do the following.
"
ActiveSheet.Range("H1") = "ISRC"
ActiveSheet.Range("H2:H" & LR1).FormulaR1C1 = "=LEFT(RC[-2],2)" "
but im stuck in a continues loop?
heres my code,
VBA Code:
Sub Open_Docs_v2()
Dim Fname As String, Pth As String
Pth = ThisWorkbook.Path & "\"
Fname = Dir(Pth & "*.csv")
Application.ScreenUpdating = False
Do Until Fname = ""
If Fname <> ThisWorkbook.Name Then
With Workbooks.Open(Pth & Fname)
LR1 = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
ActiveSheet.Range("H1") = "ISRC"
ActiveSheet.Range("H2:H" & LR1).FormulaR1C1 = "=LEFT(RC[-2],2)"
.Close True
End With
End If
Fname = Dir
Loop
End Sub
please change or just give me a better way of doing it if there is one.
thanks
Tony