combining macros

zibanitum

Board Regular
Joined
Feb 26, 2008
Messages
88
Is there a way to easily combine different macros? I have a worksheet that I use 3 different macros on. I would like to combine those to one. Is there an easy way to do this?
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
zibanitum,

Please post your macro code with code tags.


At the beginning of your posted code, enter the following without the quote marks:
["code"]


Your code goes here.


At the end of your posted code, enter the following without the quote marks:
["/code"]


Have a great day,
Stan
 
Upvote 0
Here are the 3 macros. They do what they need to do individually, but I would like them to be as 1.

Sub RemoveDuplicates()
With Application
.ScreenUpdating = False
.EnableEvents = False
Dim LC As Integer
LC = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column + 1
With Range("F1:F" & Cells(Rows.Count, 6).End(xlUp).Row)
.AdvancedFilter Action:=xlFilterInPlace, Unique:=True
.SpecialCells(12).Offset(0, LC - 6).Value = 1
On Error Resume Next
ActiveSheet.ShowAllData
Columns(LC).SpecialCells(4).EntireRow.Delete
Err.Clear
End With
Columns(LC).Clear
.EnableEvents = True
.ScreenUpdating = True
End With
End Sub
Sub Delete_Blank_Rows()
' This macro deletes all blank rows on the active worksheet
Dim rng As Range, cell As Range, del As Range
Set rng = Intersect(Range("AE:AE"), ActiveSheet.UsedRange)
For Each cell In rng
If (cell.Value) = "" Then
If del Is Nothing Then
Set del = cell
Else: Set del = Union(del, cell)
End If
End If
Next cell
On Error Resume Next
del.EntireRow.Delete
End Sub
Sub RemoveFinalCallDisposition()
Dim rngFound As Range, rngToDelete As Range, sFirstAddress As String
Dim vList, lArrCounter As Long
Application.ScreenUpdating = False

vList = Array("Complete Script", "Contact Family/Deceased", "Contact/Refused", "Contact/VM msg left", "Incomplete Script")

For lArrCounter = LBound(vList) To UBound(vList)
With Sheet1.Range("AF:AF")
Set rngFound = .Find( _
What:=vList(lArrCounter), _
After:=.Cells(1), _
Lookat:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=True)

If Not rngFound Is Nothing Then
If rngToDelete Is Nothing Then
Set rngToDelete = rngFound
Else
Set rngToDelete = Union(rngToDelete, rngFound)
End If

sFirstAddress = rngFound.Address
Set rngFound = .FindNext(After:=rngFound)

Do Until rngFound.Address = sFirstAddress
Set rngToDelete = Union(rngToDelete, rngFound)
Set rngFound = .FindNext(After:=rngFound)
Loop
End If
End With
Next lArrCounter

If Not rngToDelete Is Nothing Then rngToDelete.EntireRow.Delete
Application.ScreenUpdating = True
End Sub

Thank you for any help
 
Upvote 0
I completed an A-Level computing course back in 2000, but this is really making the old grey matter work hard. Ive found that all i do is reference the macros I want to run after the first Macro.




Sub SaveInvoiceWithNewName()
Dim NewFN As Variant
'copy invocie to a new workbook
ActiveSheet.Copy
NewFN = "C:\users\user\desktop\Inv" & Range("E5").Value & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoice
PrintInvoice


End Sub


I don't know if this is the right way of writing it but it works for me..... :)
 
Upvote 0

Forum statistics

Threads
1,214,822
Messages
6,121,765
Members
449,049
Latest member
greyangel23

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