Melanie1987
New Member
- Joined
- Jul 2, 2018
- Messages
- 5
Good afternoon.
I've been struggling and searching the forum. But can't seem to find the correct macro for my problem.
I have a working data sheet (each week more data is added)
From this sheet I would like to copy the rows to different sheets, based on the text value in column K.
That part is no problem, when the value's stay the same.
But when new values are added in column K, which doesn't have a similar sheet, I would like to have the macro create a Sheet.
Is it possible to add something in the macro that checks if there is a sheet with the same name as the value in column K.
Then copy's the rows to this sheet.
And if there is no sheet, creates a sheet with the value name, and copy's the row?
As of this moment below is my current macro.
Sub Macro2()
Dim lr As Long, lr2 As Long, r As Long
lr = Sheets("data").Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
Select Case Range("K" & r).Wrongel
Case Is = "Wrongel"
Rows(r).Copy Destination:=Sheets("Value").Range("A" & lr2 + 1)
lr2 = Sheets("Wrongel").Cells(Rows.Count, "A").End(xlUp).Row
End Select
Next r
End Sub
Thank you guys some much in advance.
Greetings,
Melanie
I've been struggling and searching the forum. But can't seem to find the correct macro for my problem.
I have a working data sheet (each week more data is added)
From this sheet I would like to copy the rows to different sheets, based on the text value in column K.
That part is no problem, when the value's stay the same.
But when new values are added in column K, which doesn't have a similar sheet, I would like to have the macro create a Sheet.
Is it possible to add something in the macro that checks if there is a sheet with the same name as the value in column K.
Then copy's the rows to this sheet.
And if there is no sheet, creates a sheet with the value name, and copy's the row?
As of this moment below is my current macro.
Sub Macro2()
Dim lr As Long, lr2 As Long, r As Long
lr = Sheets("data").Cells(Rows.Count, "A").End(xlUp).Row
For r = lr To 2 Step -1
Select Case Range("K" & r).Wrongel
Case Is = "Wrongel"
Rows(r).Copy Destination:=Sheets("Value").Range("A" & lr2 + 1)
lr2 = Sheets("Wrongel").Cells(Rows.Count, "A").End(xlUp).Row
End Select
Next r
End Sub
Thank you guys some much in advance.
Greetings,
Melanie