Hellooo
I have a code that copy value from my "Data" sheet and paste to another specific sheets. My problem is this:
1. The date to be paste is not the date in specified cell at "Data" sheet, instead the date of the last row which are not empty; and
2. i want the Date column in target sheets to be the primary key to avoid duplicates entry.
Heres the code:
Dim i As Integer
Dim lr As Long
Dim ar As Variant
Range("B3", Range("B65536").End(xlUp)).AdvancedFilter xlFilterCopy, , [G1], True
ar = Range("G2", Range("G65536").End(xlUp))
For i = 2 To Range("G65536").End(xlUp).Row
Range("B3", Range("B65536").End(xlUp)).AutoFilter 1, Range("G" & i)
Range("A4:A100, C4:C100").Copy Sheets(Range("G" & i).Value).Cells(Rows.Count, 2).End(xlUp)(2)
Sheets(ar(i - 1, 1)).Cells(Rows.Count, 1).End(xlUp)(2) = [b1]
lr = Sheets(ar(i - 1, 1)).Cells(Rows.Count, 1).End(xlUp).Row
Sheets(ar(i - 1, 1)).Range("A" & lr & ":A" & Sheets(ar(i - 1, 1)).Range("B" & Rows.Count).End(xlUp).Row).FillDown
Next i
[b3].AutoFilter
I attached the sample file for reference..
Bookmarks