Hi!
Working on a code to convert a part of a sheet into a CSV file:
Problem is that I get "Run-time error '1004': Application-defined or object-defined error" when running it, stopping at "ActiveSheet.PasteSpecial Paste:=xlPasteValues".
Any help?
Working on a code to convert a part of a sheet into a CSV file:
Problem is that I get "Run-time error '1004': Application-defined or object-defined error" when running it, stopping at "ActiveSheet.PasteSpecial Paste:=xlPasteValues".
Any help?
Code:
Sub ProdCSV()
Sheets("EM_S.06.03").Activate
'Teller antall instrumenter
nyttantall = WorksheetFunction.CountA(Range(Cells(16, 2), Cells(2000, 2)))
A30kol = WorksheetFunction.Match("C0060", Range(Cells(15, 1), Cells(15, 75)), 0)
LocationPath = Application.ThisWorkbook.Path & "\"
Filnavn11 = Range("Year2").Value & " Solvency II S.06.03.csv"
Filnavn22 = Range("Year2").Value & " Solvency II S.09.01.csv"
Filnavn1 = LocationPath & Filnavn11
Filnavn2 = LocationPath & Filnavn22
Sheets("EM_S.06.03").Range(Cells(15, 2), Cells(15 + nyttantall, A30kol)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.PasteSpecial Paste:=xlPasteValues
ActiveWorkbook.SaveAs Filename:=Filnavn1, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Sheets("EM_S.09.01").Activate
Sheets("EM_S.09.01").Range(Cells(15, 2), Cells(18, 9)).Select
Selection.Copy
Workbooks.Add
ActiveSheet.PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
ActiveWorkbook.SaveAs Filename:=Filnavn2, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
End Sub