Hi,
I'm trying to write a code that goes through sheet with raw data ("Dane") and copies case numbers (col "B") based on date (col "J") and ID (col "A"). I have worksheets named with all ID's from raw data and in these worksheets in col "A" I have the dates.
The subroutine should look through every row and match the ID with the worksheet that is named with that ID, check the date and copy the case number into that worksheet into next available column in a row that contains the date that matches with the source sheet date in col "J".
Here's what I have written (and it doesn't do a single thing):
Also adding screen shots of source and destination sheets
I'm trying to write a code that goes through sheet with raw data ("Dane") and copies case numbers (col "B") based on date (col "J") and ID (col "A"). I have worksheets named with all ID's from raw data and in these worksheets in col "A" I have the dates.
The subroutine should look through every row and match the ID with the worksheet that is named with that ID, check the date and copy the case number into that worksheet into next available column in a row that contains the date that matches with the source sheet date in col "J".
Here's what I have written (and it doesn't do a single thing):
VBA Code:
Sub Copy_to_ID_sheet()
Dim impdate As Date
Dim finalrow As Long
Dim i As Long
Dim caseno As String
Dim ID As String
finalrow = Sheets("Dane").Range("A:A").End(xlUp).Row
For i = 2 To finalrow
impdate = Sheets("Dane").Cells(i, 10)
caseno = Sheets("Dane").Cells(i, 2)
ID = Sheets("Dane").Cells(i, 1)
If ID = Sheets(ID) Then
EntireRow.copy Destination:=Sheets(ID).Range("A" & Rows.Count).End(xlUp).Offset(1)
End If
Next i
End Sub
Also adding screen shots of source and destination sheets