Hi,
I have the following code to copy data to a .csv file, I would like to ammend the code to check if the file is already open as the file will normally be open after the macro runs for the first time but if it stays open i get an error when i run the code for each time after.
Regards Damian
I have the following code to copy data to a .csv file, I would like to ammend the code to check if the file is already open as the file will normally be open after the macro runs for the first time but if it stays open i get an error when i run the code for each time after.
Code:
Sub CopyTC()
Dim wks As Worksheet
Dim sFile As String
Application.ScreenUpdating = False
Application.EnableEvents = False
Set wks = Sheet12
wks.Range("AN4:BJ4").Copy
sFile = "C:\users\damian\desktop\tankcard.csv"
With Workbooks.Open(Filename:=sFile, ReadOnly:=True, UpdateLinks:=False)
Range("A2").PasteSpecial Paste:=xlPasteValues
.Application.CutCopyMode = False
End With
Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
Regards Damian