Mark Green
Board Regular
- Joined
- Apr 15, 2016
- Messages
- 125
I got my lengthy VBA file working perfectly on Computer A.
Computer A has Excel 2002.
Just before I was going to send the file to my friend I decided to try the .xls
file on Computer B which has Excel 2013.
As luck would have it when I tried to run the macro I got a couple of errors.
The first error I got was when the first .csv import sub was run.
It stopped on the last line below.
I have no idea why.
The second error I received occurred at the following line in my code:
In order to get the main part of my macro to run, I did the .csv import manually and then continued to run the macro from right after that part.
Here's the thing. If I commented out the .csv import, the macro stopped at the spot above:
ActiveCell.End(xlDown).Offset(1, 0).Select
However if I ran the macro manually (debug mode) after the manual .csv import, it did NOT stop at the line above!
It continued without any errors right to the end!
Any ideas or suggestions would be greatly appreciated!
Computer A has Excel 2002.
Just before I was going to send the file to my friend I decided to try the .xls
file on Computer B which has Excel 2013.
As luck would have it when I tried to run the macro I got a couple of errors.
The first error I got was when the first .csv import sub was run.
It stopped on the last line below.
Code:
Sub Prod_II_csv_import()
Application.ScreenUpdating = False
Dim file_name As String
Dim output_sheet As String
Dim row_number As String
file_name = Sheets("RptAdmin").Range("B4").Value
output_sheet = Sheets("RptAdmin").Range("C4").Value
row_number = Sheets("RptAdmin").Range("D4").Value
With Sheets(output_sheet).QueryTables.Add(Connection:= _
"TEXT;" + file_name, Destination:=Sheets(output_sheet).Range("$A$" + row_number))
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimiter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimiter = False
.TextFileCommaDelimiter = True
.TextFileSpaceDelimiter = False
.TextFileTrailingMinusNumbers = True
.Refresh BackgroundQuery:=False <------------------
End With
End Sub
I have no idea why.
The second error I received occurred at the following line in my code:
Code:
Range("G8").Select ' Total Profit calculated
ActiveCell.End(xlDown).Offset(1, 0).Select <-----------------
In order to get the main part of my macro to run, I did the .csv import manually and then continued to run the macro from right after that part.
Here's the thing. If I commented out the .csv import, the macro stopped at the spot above:
ActiveCell.End(xlDown).Offset(1, 0).Select
However if I ran the macro manually (debug mode) after the manual .csv import, it did NOT stop at the line above!
It continued without any errors right to the end!
Any ideas or suggestions would be greatly appreciated!