hi
i have the below code
Two questions
#1 how can i modify the code that i can select in an input box where the header ends suppose i want my header to be row 1,2,3
#2 instead of changing the sheet name in the code ,how can i have this code modified, to be the active sheet that i'm on right now
i have the below code
Code:
[COLOR=#333333]Sub sheets_from_colb()[/COLOR][COLOR=#333333]<code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
Const cl& = 3
Dim a As Variant, x As Worksheet, sh As Worksheet
Dim rws&, cls&, p&, i&, rr&, b As Boolean
Application.ScreenUpdating = False
Sheets("main sheet ").Activate
rws = Cells.Find("*", , , , xlByRows, xlPrevious).Row
cls = Cells.Find("*", , , , xlByColumns, xlPrevious).Column
Set x = Sheets.Add(After:=Sheets("main sheet "))
Sheets("main sheet ").Cells(1).Resize(rws, cls).Copy x.Cells(1)
Set a = x.Cells(1).Resize(rws, cls)
a.Sort a(1, cl), 2, Header:=xlYes
a = a.Resize(rws + 1)
p = 2
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)
Sheets.Add.Name = a(p, cl)
With Sheets(a(p, cl))
x.Cells(1).Resize(, cls).Copy .Cells(1)
rr = .Cells.Find("*", , , , xlByRows, xlPrevious).Row + 1
x.Cells(p, 1).Resize(i - p, cls).Cut .Cells(rr, 1)
End With
End If
p = i
End If
Next i
Application.DisplayAlerts = False
x.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub</code><code style="margin: 0px; padding: 0px; font-style: inherit; font-weight: inherit; line-height: 12px;">
</code>
[/COLOR]
Two questions
#1 how can i modify the code that i can select in an input box where the header ends suppose i want my header to be row 1,2,3
#2 instead of changing the sheet name in the code ,how can i have this code modified, to be the active sheet that i'm on right now