Macro Help

Kyosti

Board Regular
Joined
Jun 2, 2008
Messages
90
So you guys helped me before, need it again. I built this Macro based on help from you guys, but I only understand half the language. I need to have the macro work exactly as it is, however when it names each tab, I need it to have the word Late added to it. Please help.

Sub VendorSplit()
'
' VendorSplit Macro
'
Dim Cl As Range
Dim WS As Worksheet
Dim Ky As Variant

Columns("E:E").Select
Selection.Replace What:="FULL ", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Selection.Replace What:="TPP", Replacement:="TRANSFER", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Range("A1").Select

Set WS = Sheets("Data")
With CreateObject("scripting.dictionary")
For Each Cl In WS.Range("O2", WS.Range("O" & Rows.Count).End(xlUp))
.Item(Cl.Value) = Empty
Next Cl
For Each Ky In .Keys
WS.Range("A1:O1").AutoFilter 15, Ky
Sheets.Add(, Sheets(Sheets.Count)).Name = Ky
WS.AutoFilter.Range.SpecialCells(xlVisible).EntireRow.Copy Range("A1")
Next Ky

Dim Wsht As Worksheet
For Each Wsht In Worksheets
With Wsht.UsedRange
.EntireColumn.AutoFit
End With
Next Wsht

Range("A1").Select
Sheets("Data").Select
Range("DataTable[[#Headers],[Original Producer Number]]").Select
ActiveSheet.ListObjects("DataTable").Range.AutoFilter Field:=15
ActiveWindow.SmallScroll Down:=-30

Cells.Select
Selection.ColumnWidth = 14
Range("DataTable[[#Headers],[Original Producer Number]]").Select

For i = 1 To Application.Sheets.Count
For j = 1 To Application.Sheets.Count - 1
If UCase$(Application.Sheets(j).Name) > UCase$(Application.Sheets(j + 1).Name) Then
Sheets(j).Move after:=Sheets(j + 1)

Sheets("Data").Select
Sheets("Data").Move Before:=Sheets(1)


End If
Next
Next
End With
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Change
Code:
Sheets.Add(, Sheets(Sheets.Count)).Name = Ky
to
Code:
Sheets.Add(, Sheets(Sheets.Count)).Name = Ky & " Late"
However if any of the values in col O are more than 26 characters long you will get an error
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,337
Members
452,637
Latest member
Ezio2866

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top