dweingar16
New Member
- Joined
- Oct 17, 2017
- Messages
- 3
I am creating a data file in excel that creates a spreadsheet in my primary workbook (Main), then cleans it up, and then creates a new workbook named test.xlsx that the data is pasted into. When I try and import the data from the test.xlsx file into another application it does not work. If I copy and paste the data from test.xlsx into a file with a name other than test.xlsx, it works. Help. This is the VBA code that is creating the new workbook.
Dim FName As String
Dim FPath As String
Dim wb As Workbook
Set wb = Workbooks.Add
Set xls = CreateObject("Excel.Application")
xls.DisplayAlerts = False
ThisWorkbook.Sheets("Main").Copy Before:=wb.Sheets(1)
'Clean up
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("I:Z").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'sbDelete_Rows_IF_Cell_Contains_String_Text_Value()
Dim lRow2 As Long
Dim iCntr2 As Long
lRow2 = 390
For iCntr2 = lRow2 To 1 Step -1
If Cells(iCntr2, 6).Value = "0" Then
Rows(iCntr2).Delete
End If
Next
' ActiveSheet.Shapes.Range(Array("Button 1")).Select
' Selection.Delete
wb.SaveAs "H:\Test.xlsx", AccessMode:=xlExclusive, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
ActiveWorkbook.Close
wb.Close (True)
Dim FName As String
Dim FPath As String
Dim wb As Workbook
Set wb = Workbooks.Add
Set xls = CreateObject("Excel.Application")
xls.DisplayAlerts = False
ThisWorkbook.Sheets("Main").Copy Before:=wb.Sheets(1)
'Clean up
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Columns("I:Z").Select
Application.CutCopyMode = False
Selection.Delete Shift:=xlToLeft
'sbDelete_Rows_IF_Cell_Contains_String_Text_Value()
Dim lRow2 As Long
Dim iCntr2 As Long
lRow2 = 390
For iCntr2 = lRow2 To 1 Step -1
If Cells(iCntr2, 6).Value = "0" Then
Rows(iCntr2).Delete
End If
Next
' ActiveSheet.Shapes.Range(Array("Button 1")).Select
' Selection.Delete
wb.SaveAs "H:\Test.xlsx", AccessMode:=xlExclusive, ConflictResolution:=Excel.XlSaveConflictResolution.xlLocalSessionChanges
ActiveWorkbook.Close
wb.Close (True)