I am importing 2 csv files into the same sheet. The first set of dates writes to the cell formated as General and displays as mm/dd/yyyy. The next csv with the same date is written to the cell as custom '*m/dd/yyyy'.
I can see in the process the dates held in the variable before it is written to the cell are identical - "mm/dd/yyyy " yet they are written to the cell differently and I don't understand.
Both .csv files store the values like "02/02/2013 "
here are the 2 records from the .csv files
"WILLIE","BARBER","02/02/2013 ","252.8","22 ","11.49","0 ","0","0 ","22.99","0","",,,,"Posted",,,,,
"WILLIE","BARBER","02/02/2013 ","247.81","22","11.5","0","17.25","0","0","-5.19"," FEES/DISCOUNTS","05238618","2413 ","B5641 "," ",,"767048",,,
Both are added to the sheet with the same Public Function
Public Function ReadExc(filename, rpt)
'Reads data from file
'variable is passed for filename to read from
'and rpt name
Open filename For Input As #1
While Not EOF(1)
Input #1, fname, lname, we, Amt, regHrs, regRate, otHrs, _
otRate, dblhrs, dblrate, miscAmt, MiscDesc, Invoice, Branch, _
OrdNum, Status, OrigWE, client, ssnum, extra1, extra2
ActiveCell = rpt
ActiveCell.offset(0, 1) = fname
ActiveCell.offset(0, 2) = lname
ActiveCell.offset(0, 3) = we
ActiveCell.offset(0, 4) = Amt
ActiveCell.offset(0, 5) = regHrs
ActiveCell.offset(0, 6) = regRate
ActiveCell.offset(0, 7) = otHrs
ActiveCell.offset(0, 8) = otRate
ActiveCell.offset(0, 9) = dblhrs
ActiveCell.offset(0, 10) = dblrate
ActiveCell.offset(0, 11) = miscAmt
ActiveCell.offset(0, 12) = MiscDesc
ActiveCell.offset(0, 13) = Invoice
ActiveCell.offset(0, 14) = Branch
ActiveCell.offset(0, 15) = OrdNum
ActiveCell.offset(0, 16) = Status
ActiveCell.offset(0, 17) = OrigWE
ActiveCell.offset(0, 18) = client
ActiveCell.offset(0, 19) = ssnum
ActiveCell.offset(0, 20) = extra1
ActiveCell.offset(0, 21) = extra2
ActiveCell.offset(1, 0).Activate
Wend
Close #1
End Function
Both .csv use same Public Function to write to seperate files.
Public Function WriteExc(filename, sht, Rng)
'Writes data to file
'variables for filename to write to, sheet to write from
'and starting range
Open filename For Output As #1
Sheets(sht).Select
Range(Rng).Select
While ActiveCell.offset(0, 2) > 0
Write #1, RTrim(ActiveCell), RTrim(ActiveCell.offset(0, 1)), _
ActiveCell.offset(0, 2), ActiveCell.offset(0, 3), _
ActiveCell.offset(0, 4), ActiveCell.offset(0, 5), _
ActiveCell.offset(0, 6), ActiveCell.offset(0, 7), _
ActiveCell.offset(0, 8), ActiveCell.offset(0, 9), _
ActiveCell.offset(0, 10), RTrim(ActiveCell.offset(0, 11)), _
ActiveCell.offset(0, 12), ActiveCell.offset(0, 13), _
ActiveCell.offset(0, 14), ActiveCell.offset(0, 15), _
ActiveCell.offset(0, 16), ActiveCell.offset(0, 17), _
ActiveCell.offset(0, 18), ActiveCell.offset(0, 19), _
ActiveCell.offset(0, 20)
ActiveCell.offset(1, 0).Activate
Wend
Close #1
End Function
Anyone got any ideas?
Thanks,
Joel
Joel
I can see in the process the dates held in the variable before it is written to the cell are identical - "mm/dd/yyyy " yet they are written to the cell differently and I don't understand.
Both .csv files store the values like "02/02/2013 "
here are the 2 records from the .csv files
"WILLIE","BARBER","02/02/2013 ","252.8","22 ","11.49","0 ","0","0 ","22.99","0","",,,,"Posted",,,,,
"WILLIE","BARBER","02/02/2013 ","247.81","22","11.5","0","17.25","0","0","-5.19"," FEES/DISCOUNTS","05238618","2413 ","B5641 "," ",,"767048",,,
Both are added to the sheet with the same Public Function
Public Function ReadExc(filename, rpt)
'Reads data from file
'variable is passed for filename to read from
'and rpt name
Open filename For Input As #1
While Not EOF(1)
Input #1, fname, lname, we, Amt, regHrs, regRate, otHrs, _
otRate, dblhrs, dblrate, miscAmt, MiscDesc, Invoice, Branch, _
OrdNum, Status, OrigWE, client, ssnum, extra1, extra2
ActiveCell = rpt
ActiveCell.offset(0, 1) = fname
ActiveCell.offset(0, 2) = lname
ActiveCell.offset(0, 3) = we
ActiveCell.offset(0, 4) = Amt
ActiveCell.offset(0, 5) = regHrs
ActiveCell.offset(0, 6) = regRate
ActiveCell.offset(0, 7) = otHrs
ActiveCell.offset(0, 8) = otRate
ActiveCell.offset(0, 9) = dblhrs
ActiveCell.offset(0, 10) = dblrate
ActiveCell.offset(0, 11) = miscAmt
ActiveCell.offset(0, 12) = MiscDesc
ActiveCell.offset(0, 13) = Invoice
ActiveCell.offset(0, 14) = Branch
ActiveCell.offset(0, 15) = OrdNum
ActiveCell.offset(0, 16) = Status
ActiveCell.offset(0, 17) = OrigWE
ActiveCell.offset(0, 18) = client
ActiveCell.offset(0, 19) = ssnum
ActiveCell.offset(0, 20) = extra1
ActiveCell.offset(0, 21) = extra2
ActiveCell.offset(1, 0).Activate
Wend
Close #1
End Function
Both .csv use same Public Function to write to seperate files.
Public Function WriteExc(filename, sht, Rng)
'Writes data to file
'variables for filename to write to, sheet to write from
'and starting range
Open filename For Output As #1
Sheets(sht).Select
Range(Rng).Select
While ActiveCell.offset(0, 2) > 0
Write #1, RTrim(ActiveCell), RTrim(ActiveCell.offset(0, 1)), _
ActiveCell.offset(0, 2), ActiveCell.offset(0, 3), _
ActiveCell.offset(0, 4), ActiveCell.offset(0, 5), _
ActiveCell.offset(0, 6), ActiveCell.offset(0, 7), _
ActiveCell.offset(0, 8), ActiveCell.offset(0, 9), _
ActiveCell.offset(0, 10), RTrim(ActiveCell.offset(0, 11)), _
ActiveCell.offset(0, 12), ActiveCell.offset(0, 13), _
ActiveCell.offset(0, 14), ActiveCell.offset(0, 15), _
ActiveCell.offset(0, 16), ActiveCell.offset(0, 17), _
ActiveCell.offset(0, 18), ActiveCell.offset(0, 19), _
ActiveCell.offset(0, 20)
ActiveCell.offset(1, 0).Activate
Wend
Close #1
End Function
Anyone got any ideas?
Thanks,
Joel
Joel