Hi
The above code has been working great (no surprise as you are all genii
)
However I am now needing to use the same (similar) code, but instead of it being split into 2 sheets depending on the data in Col G ( It was on age) into 3 named sheets based on the data in the column, which has changed.
The data in the column is now either an S4, S5 or S6.
So on the click of the button take the master data list and copy it to the relevant worksheet based on if the value in Col G is S4, S5 or S6
I have tried to tweak the original code, I know the line that needs changing, but I'm not hitting the lucky jackpot it would seem.
I can get it to copy it to one of the named sheets, but the data doesn't split up.......
Original code below, and the line that I know I need to change is Line 11 fat the IF function part
Any help would be very much appreciated as always
Sub TransferData()
Dim ar As Variant
Dim sh As Worksheet, ws As Worksheet
Dim i As Integer
Dim lr As Long
Set sh = Sheets("Master List")
lr = sh.Range("A" & Rows.Count).End(xlUp).Row
sh.Range("X3:X" & lr) = "=IF(G3<=12,""U12s"",""U14s"")" '---->Formula placed in Column X of Master List to define sheets in the array.
ar = sh.Range("X3", sh.Range("X" & sh.Rows.Count).End(xlUp))
Application.ScreenUpdating = False
For i = 1 To UBound(ar)
Set ws = Sheets(ar(i, 1))
ws.UsedRange.Offset(1).ClearContents
sh.Range("X2:X" & lr).AutoFilter 1, ar(i, 1)
sh.Range("A3:G" & lr).Copy
ws.Range("A" & Rows.Count).End(3)(2).PasteSpecial xlValues
ws.Columns.AutoFit
sh.[X2].AutoFilter
Next i
sh.Select
[COLOR=#FF0000]sh.[A1].AutoFilter[/COLOR]
sh.Columns(24).ClearContents
Application.CutCopyMode = False
Application.ScreenUpdating = True
MsgBox "Data transfer completed!", vbExclamation, "Status"
End Sub
Display More