Hi All,
I'm new to macros and was hoping someone here could help me out. I'm currently using the code (found it on one of these forums) below to split data based on criteria in column A from a master workseet onto several existing worksheets (One tab for each salesman). This code works great but adds the data to the first non-blank row in the existing sheets. I would like for it to overwrite any data as this workbook is updated monthly and should only reflect current month activity. Any help would be greatly appreciated!!
Sub Split()
Dim rng As Range
Dim rng1 As Range
Dim vrb As Boolean
Dim sht As Worksheet
Set rng = Sheets("Total").Range("A4")
Set rng1 = Sheets("Total").Range("A4:H4")
vrb = False
Do While rng <> ""
For Each sht In Worksheets
If sht.name = Left(rng.Value, 31) Then
sht.Select
Range("A2").Select
Do While Selection <> ""
ActiveCell.Offset(1, 0).Activate
Loop
rng1.Copy ActiveCell
ActiveCell.Offset(1, 0).Activate
Set rng1 = rng1.Offset(1, 0)
Set rng = rng.Offset(1, 0)
vrb = True
End If
Next sht
If vrb = False Then
Sheets.Add after:=Sheets(Sheets.Count)
ActiveSheet.name = Left(rng.Value, 31)
Sheets("Total").Range("A3:H3").Copy ActiveSheet.Range("A1")
Range("A2").Select
Do While Selection <> ""
ActiveCell.Offset(1, 0).Activate
Loop
rng1.Copy ActiveCell
Set rng1 = rng1.Offset(1, 0)
Set rng = rng.Offset(1, 0)
End If
vrb = False
Loop
End Sub
Bookmarks