Hello, how can I combine these three macros so they run one after the other instead of me running them one at a time? the first macro, results in a new tab called "New". Once the first macro is ran, and the "New" tab is created, I have this tab active and run the other two macros one at a time.
2nd macro:
3rd macro:
VBA Code:
Sub Rearange_Order()
'
Sheets("variable colums").Select
i = Sheets("variable colums").Index
Sheets.Add
Sheets(i).Name = "New"
Last_Col_Fixed = Sheets("fixed columns").Range("IV1").End(xlToLeft).Column
Last_Col_Variable = Sheets("variable colums").Range("IV1").End(xlToLeft).Column
I_Col_New = 1
For i = 1 To Last_Col_Fixed
Search_Header = Sheets("fixed columns").Cells(1, i)
Sheets("variable colums").Select
Set C = Range(Cells(1, 1), Cells(1, Last_Col_Variable)).Find(Search_Header, LookIn:=xlValues)
If (Not (C) Is Nothing) Then
Cells(1, C.Column).EntireColumn.Copy Sheets("New").Cells(1, I_Col_New)
I_Col_New = I_Col_New + 1
End If
Next i
End Sub
2nd macro:
VBA Code:
Sub StringsCheck()
Dim rng As Range
For Each rng In Range("A1", Cells(1, Columns.Count).End(1))
If InStr(rng.Value, "Rate") Or InStr(rng.Value, "percentage") Then
With Range(Cells(2, rng.Column), Cells(Rows.Count, rng.Column).End(3))
.Value = Evaluate("=" & .Address & " / 100")
.Style = "Percent"
.NumberFormat = "0.00%"
End With
End If
Next rng
End Sub
3rd macro:
VBA Code:
Sub replace_on_two_columns_2()
Dim a As Variant
Dim i As Long
Application.ScreenUpdating = False
With ActiveSheet.Range("BK2:BL" & ActiveSheet.Range("BL" & Rows.Count).End(3).Row)
a = .Value
ReDim b(1 To UBound(a, 1), 1 To 2)
For i = 1 To UBound(a)
If a(i, 1) <> "" Then
b(i, 1) = finaldata_2(replacedata(a(i, 1)))
End If
If a(i, 2) <> "" Then
b(i, 2) = finaldata_2(replacedata(a(i, 2)))
End If
Next
.Value = b
End With
End Sub
Function replacedata(data)
data = Replace(Replace(data, "_GUAR", "", , , vbTextCompare), ",", " ")
data = Replace(data, "HEALTHMART", "HM", , , vbTextCompare)
replacedata = Replace(data, "HEALTH MART", "HM", , , vbTextCompare)
End Function
Function finaldata_2(data)
Dim a As Variant, itm As Variant
Dim valores As New Collection
Dim bex As Boolean
Dim i As Long
For Each itm In Split(data, " ")
bex = False
For i = 1 To valores.Count
Select Case StrComp(valores(i), itm, vbTextCompare)
Case 0
bex = True
Exit For
Case 1
bex = True
valores.Add itm, itm, Before:=i
Exit For
End Select
Next
If bex = False Then valores.Add itm, itm
Next
ReDim a(1 To valores.Count)
For i = 1 To valores.Count
a(i) = valores(i)
Next
finaldata_2 = Join(a, " ")
End Function