This code work just fine
Private Sub FormatDate_Click()
'===================================================================================================
'FormatDate
'===================================================================================================
Dim Archive_Date, x As Variant
Dim CellDate As String
Set Archive_Date = Workbooks("Archives.XLS").Sheets("ArchiveDoc").Range("D2", Range("D" & Rows.Count).End(xlUp))
For Each x In Archive_Date
CellDate = x.Value
x.Value = Format(CellDate, "DD.MM.YYYY")
Next x
End Sub
But if i put another set for other file i get run time error
Private Sub CopyData_Click()
'===================================================================================================
'Copy Column From Payment_File to Archive_File
'===================================================================================================
Dim PaymentOrderBase, Archive_Invoice As Range
Dim x As Variant, y As Variant
Dim OrderPayment As String
Dim OrderArchive, F As String
Dim wb As Workbook
Set wb = _
Workbooks.Open("H:\Motorup\MotorUp-150409\Warranty\Payment\Test\PaymentReport.xls")
'wb.Activate
Set PaymentOrderBase = Workbooks("PaymentReport.XLS").Sheets("PaymentDoc").Range("B2", Range("B" & Rows.Count).End(xlUp))
'============================================
'for Archive_Invoice Set i get an error 1004
'============================================
Set Archive_Invoice = Workbooks("Archives.XLS").Sheets("ArchiveDoc").Range("C2", Range("C" & Rows.Count).End(xlUp))
For Each x In PaymentOrderBase
For Each y In Archive_Invoice
'Compare between invoices And Orders in Archive_File and Payment_File
OrderPayment = Left(x.Offset(0, -1), 6)
' OrderArchive = y.Offset(0, -1)
If x = y And OrderPayment = OrderArchive Then
'Copy invoices from invoice column b:3 to column h:3
y.Offset(0, 6) = x
'copy order column from Payment_File to Archive_File
y.Offset(0, 5) = x.Offset(0, -1)
'copy Payment column from Payment_File to Archive_File
y.Offset(0, 3) = x.Offset(0, 3)
'copy type column from Payment_File to Archive_File
y.Offset(0, 7) = x.Offset(0, 4)
End If
Next y
Next x
End Sub
what is the problem?
Bookmarks