Hello,
I have a macro that takes data downloaded and paste special from one system, codes, reorganizes, formats, and saves it as a ".csv" with a unique name depending on a cell value. The template does all this so this data can be uploaded into a new system. It seems to work fine except each file fails the upload into the new system unless you open it, save it, close it and reupload. then it works. the only difference I see is having to reopen and save. How can I fix this? We are talking about tens of thousands of files and those two additional steps will be a nightmare. The Mini sheet below does not include the conversion or instructions that would be very hidden. These sheets are not part of the upload once the save function has been selected and the workbook is renamed as a .csv file. Thank you in advance. Code below as I could not upload the mini sheet I created for this. Other pertinent information, using MicroSoft 360.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$P$2" Then
Select Case Target.Value
Case "Clear":
Range("A:P").ClearContents
Range("A1").FormulaR1C1 = "Paste Special Here"
Range("A1").Interior.Color = RGB(223, 202, 228)
Range("J1").FormulaR1C1 = "L / M #"
Range("L1").FormulaR1C1 = "Name"
Range("L4").FormulaR1C1 = "Your File's Name:"
Range("L5").FormulaR1C1 = "=IF(R[-4]C[-11]=""Paste Special Here"","""",IF(R[-3]C[-2]="""",R[-3]C[-11]&"" - ""&R[-3]C&"" - ""&R[-3]C[2],R[-3]C[-2]&"" - ""&R[-3]C&"" - ""&R[-3]C[2]))"
Range("N1").FormulaR1C1 = "Reviewer #"
Range("P1").FormulaR1C1 = "Functions"
Range("P2").Interior.Color = RGB(241, 232, 238)
Sheets("Instructions").Visible = xlVeryHidden
Case "Instructions":
Sheets("Instructions").Visible = True
Sheets("Instructions").Select
Case "Save":
Range("A:H").NumberFormat = "General"
Range("A1").Interior.Color = xlNone
Range("A:A").Insert Shift:=xlToRight
Range("C:C").Cut Destination:=Columns("A:A")
Range("E:E").Cut Destination:=Columns("C:C")
Range("D:D").Cut Destination:=Columns("E:E")
Range("F:F").Cut Destination:=Columns("D:D")
Range("I:I").Cut Destination:=Columns("F:F")
Range("G2:G" & Cells(Rows.Count, "H").End(xlUp).Row).FormulaR1C1 = "=IF(OR(RC[1]="""",RC[1]=0),"""",VLOOKUP(RC[1],Converter!C[-5]:C[-3],2,FALSE))"
Range("I2:I" & Cells(Rows.Count, "H").End(xlUp).Row).FormulaR1C1 = "=IF(OR(RC[-1]="""",RC[-1]=0),"""",VLOOKUP(RC[-1],Converter!C[-7]:C[-5],3,False))"
Range("A1").FormulaR1C1 = "TimePeriod"
Range("B1").FormulaR1C1 = "AccountId"
Range("C1").FormulaR1C1 = "Type"
Range("D1").FormulaR1C1 = "Acquisition"
Range("E1").FormulaR1C1 = "Accelerated"
Range("F1").FormulaR1C1 = "Cost"
Range("G1").FormulaR1C1 = "Table"
Range("I1").FormulaR1C1 = "Life"
Range("A:I").Copy
Range("A:I").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I:I").Cut Destination:=Columns("H:H")
Range("I:I").Delete
ActiveSheet.Name = Range("L5")
Range("J:P").Delete
Range("A2").Select
ActiveWorkbook.SaveAs Filename:= _
"P:\Confidential\Confidential\" & Sheet.Name & ".csv", _
FileFormat:=xlCSVUTF8, CreateBackup:=False
Range("I:P").Delete
Range("A1").Select
ActiveWorkbook.Save
End Select
End If
End Sub
I have a macro that takes data downloaded and paste special from one system, codes, reorganizes, formats, and saves it as a ".csv" with a unique name depending on a cell value. The template does all this so this data can be uploaded into a new system. It seems to work fine except each file fails the upload into the new system unless you open it, save it, close it and reupload. then it works. the only difference I see is having to reopen and save. How can I fix this? We are talking about tens of thousands of files and those two additional steps will be a nightmare. The Mini sheet below does not include the conversion or instructions that would be very hidden. These sheets are not part of the upload once the save function has been selected and the workbook is renamed as a .csv file. Thank you in advance. Code below as I could not upload the mini sheet I created for this. Other pertinent information, using MicroSoft 360.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$P$2" Then
Select Case Target.Value
Case "Clear":
Range("A:P").ClearContents
Range("A1").FormulaR1C1 = "Paste Special Here"
Range("A1").Interior.Color = RGB(223, 202, 228)
Range("J1").FormulaR1C1 = "L / M #"
Range("L1").FormulaR1C1 = "Name"
Range("L4").FormulaR1C1 = "Your File's Name:"
Range("L5").FormulaR1C1 = "=IF(R[-4]C[-11]=""Paste Special Here"","""",IF(R[-3]C[-2]="""",R[-3]C[-11]&"" - ""&R[-3]C&"" - ""&R[-3]C[2],R[-3]C[-2]&"" - ""&R[-3]C&"" - ""&R[-3]C[2]))"
Range("N1").FormulaR1C1 = "Reviewer #"
Range("P1").FormulaR1C1 = "Functions"
Range("P2").Interior.Color = RGB(241, 232, 238)
Sheets("Instructions").Visible = xlVeryHidden
Case "Instructions":
Sheets("Instructions").Visible = True
Sheets("Instructions").Select
Case "Save":
Range("A:H").NumberFormat = "General"
Range("A1").Interior.Color = xlNone
Range("A:A").Insert Shift:=xlToRight
Range("C:C").Cut Destination:=Columns("A:A")
Range("E:E").Cut Destination:=Columns("C:C")
Range("D:D").Cut Destination:=Columns("E:E")
Range("F:F").Cut Destination:=Columns("D:D")
Range("I:I").Cut Destination:=Columns("F:F")
Range("G2:G" & Cells(Rows.Count, "H").End(xlUp).Row).FormulaR1C1 = "=IF(OR(RC[1]="""",RC[1]=0),"""",VLOOKUP(RC[1],Converter!C[-5]:C[-3],2,FALSE))"
Range("I2:I" & Cells(Rows.Count, "H").End(xlUp).Row).FormulaR1C1 = "=IF(OR(RC[-1]="""",RC[-1]=0),"""",VLOOKUP(RC[-1],Converter!C[-7]:C[-5],3,False))"
Range("A1").FormulaR1C1 = "TimePeriod"
Range("B1").FormulaR1C1 = "AccountId"
Range("C1").FormulaR1C1 = "Type"
Range("D1").FormulaR1C1 = "Acquisition"
Range("E1").FormulaR1C1 = "Accelerated"
Range("F1").FormulaR1C1 = "Cost"
Range("G1").FormulaR1C1 = "Table"
Range("I1").FormulaR1C1 = "Life"
Range("A:I").Copy
Range("A:I").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("I:I").Cut Destination:=Columns("H:H")
Range("I:I").Delete
ActiveSheet.Name = Range("L5")
Range("J:P").Delete
Range("A2").Select
ActiveWorkbook.SaveAs Filename:= _
"P:\Confidential\Confidential\" & Sheet.Name & ".csv", _
FileFormat:=xlCSVUTF8, CreateBackup:=False
Range("I:P").Delete
Range("A1").Select
ActiveWorkbook.Save
End Select
End If
End Sub