I have a procedure that moves a row based on a cell value.
This is hard coded into the procedure i.e. if a cell in column A matches "MW" move the row to worksheet "MW"
I must manually update / duplicate the procedures to add additional options.
Sub Procedure1()
Dim c As Range
Dim LastRow As Long
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
For Each c In ActiveSheet.Range("A2", "A" & LastRow)
If c.Value = "MW" Then
c.Offset(0, 0).Select
Selection.Resize(Selection.Rows.Count, Selection.Columns.Count + 5).Copy _
Destination:=Worksheets("MW").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0)
End If
Next c
End Sub
I would like this to be more dynamic so it can check against a reference column and then move the rows accordingly.
If the cell has a value that matched any in the reference (Column U), it would then move the row to the matching worksheet.
i.e. if it matches "MW" in the reference column (Column U) it moves to the "MW" worksheet, if it matches "SW" in the reference table (Column U) it moves it to the "SW" worksheet etc.
This way all I need to do is keep the reference column up to date and keep a single procedure in VBA that does not need to be changed.
I already have code to create the worksheets based on unique values so please assume there will be a worksheet available to move to.
Thanks
Bookmarks