hello
I have this code it creates sheets based on column b , but the problem if I change data in main sheet like add data or delete it nothing happens in sheets are already created , so I want update data in all sheets when changes in sheet1
any suggestion to mod the code or alternitave
Sub new_sheetx()
Const cl& = 2
Const ss As String = "sheet1"
Dim a As Variant, x As Worksheet, sh As Worksheet
Dim rws&, cls&, p&, i&, ri&, j&
Dim b As Boolean
Sheets(ss).Activate
rws = Cells.Find("*", , , , xlByRows, xlPrevious).Row
cls = Cells.Find("*", , , , xlByColumns, xlPrevious).Column
Set x = Sheets.Add(After:=Sheets(ss))
Sheets(ss).Cells(3, 1).Resize(rws - 2, cls).Copy x.Cells(1)
Set a = x.Cells(1).Resize(rws, cls)
a.Sort a(1, cl), 2, Header:=xlNo
a = a.Resize(rws + 1)
p = 1
For i = p To rws + 1
If a(i, cl) <> a(p, cl) Then
b = False
For Each sh In Worksheets
If sh.Name = a(p, cl) Then b = True: Exit For
Next
If Not b Then
Sheets.Add.Name = a(p, cl)
With Sheets(a(p, cl))
x.Cells(1).Resize(, cls).Copy .Cells(3, 1)
ri = i - p
x.Cells(p, 1).Resize(ri, cls).Cut .Cells(3, 1)
Sheets(ss).Cells(1).Resize(2, cls).Copy .Cells(1)
End With
End If
p = i
End If
Next i
Application.DisplayAlerts = False
x.Delete
Application.DisplayAlerts = True
End Sub
thanks in advance