connect macros run one

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Connect Macros to run one after the other | Excel forum

Connect Macros to run one after the other | Excel forum

resolvedResolved · High Priority · Version 365

Annika has attended:
Excel VBA Introduction course
Excel Power Query course

Connect Macros to run one after the other

Hey,
I have set up several codes (as below) but I can not figure out how to connect two of them to automatically run all in one go. it seems that currently, i need to run them one after the other....

In case of interest, the data is copied from an email into excel.

The problem occurs between 'CHANGE TEXT TO NUMBERS' and ' Copy_Paste_Year_Values' - somehow the update / changes stop after 'CHANGE TEXT TO NUMBERS' and it wont go on....


Sub Prep_UKCont_Data()

'REMOVE SUBS MACRO - UKCONT
'


With ActiveSheet
.AutoFilterMode = False
With Range("C1", Range("C" & Rows.Count).End(xlUp))
.AutoFilter 1, "S"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With




'COPY BUILD YEAR AND POSITION DATE FORMULA TO LAST ROW OF DATA'

'

Dim lastrow As Long
lastrow = Cells(Rows.Count, "h").End(xlUp).Row
Range("I4:K4").Select
Selection.Copy
Range("I5:I" & lastrow).Select
ActiveSheet.Paste
End




'Copy_and_Past_Values Macro
'

'
ActiveWindow.SmallScroll Down:=-18
Range("J5:J121").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=-216
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



'CHANGE TEXT TO NUMBERS'

Range("J5:J121").Select
With Selection
.NumberFormat = "General"
.Value = .Value
End With




' Copy_Paste_Year_Values'
'

'
Range("K5:K121").Select
Application.CutCopyMode = False
Selection.Copy
ActiveWindow.SmallScroll Down:=-207
Range("H5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

End Sub



Sub PASTE_UKC_DATA()
'
' PASTE_UKC_DATA Macro'
'

'
Sheets("UKC Position List Download").Select
Range("A5:C9").Select
ActiveWindow.SmallScroll Down:=228
Range("A5:J249").Select
Selection.ClearContents
Sheets("UKC POSITION FORMAT").Select
ActiveWindow.SmallScroll Down:=-27
Range("B5:H33").Select
ActiveWindow.SmallScroll Down:=195
Range("B5:H221").Select
Selection.Copy
Sheets("UKC Position List Download").Select
ActiveWindow.SmallScroll Down:=-261
Range("D5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



'COPY VESSEL AGE, AGE GROUPING AND MONTH OPEN FORMULA TO LAST ROW OF DATA'

Sheets("UKC Position List Download").Select
Dim lastrow As Long
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
Range("A3:C3").Select
Selection.Copy
Range("A5:A" & lastrow).Select
ActiveSheet.Paste
End



End Sub



Thanks!

Annika

RE: Connect Macros to run one after the other

Hi Annika,


Thank you for the forum question.

If you want to run several macros one after each other

Sub RunALL()

Call Prep_UKCont_Data
Call PASTE_UKC_DATA

End Sub

I cannot see any reasons for the code to stop here

'CHANGE TEXT TO NUMBERS'

Range("J5:J121").Select
With Selection
.NumberFormat = "General"
.Value = .Value
End With


' Copy_Paste_Year_Values'

Have you tried to step the code? The code shouldn't stop.

I do not know how sensitive the data are, but if you send me a copy of the file and can have a closer look at it.

Email:

info@stl-traiining.co.uk

if you send me and example file please write in the subject that the file is for me.




Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

RE: Connect Macros to run one after the other

Thank you Jens,
I have sent the email :-)

RE: Connect Macros to run one after the other

Hi Annika,

I have removed END twice in the code and removed scroll lines. Scroll lines are just making the code run slow and we get them when we record macros.

I hope the code will run as you want it, otherwise please let me know.


Sub Prep_UKCont_Data()

'REMOVE SUBS MACRO - UKCONT
'


With ActiveSheet
.AutoFilterMode = False
With Range("C1", Range("C" & Rows.Count).End(xlUp))
.AutoFilter 1, "S"
On Error Resume Next
.Offset(1).SpecialCells(12).EntireRow.Delete
End With
.AutoFilterMode = False
End With




'COPY BUILD YEAR AND POSITION DATE FORMULA TO LAST ROW OF DATA'

'

Dim lastrow As Long
lastrow = Cells(Rows.Count, "h").End(xlUp).Row
Range("I4:K4").Select
Selection.Copy
Range("I5:I" & lastrow).Select
ActiveSheet.Paste





'Copy_and_Past_Values Macro
'

'

Range("J5:J121").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



'CHANGE TEXT TO NUMBERS'

Range("J5:J121").Select
With Selection
.NumberFormat = "General"
'.Value = .Value
End With


' Copy_Paste_Year_Values
' Range("K5:K121").Select
Application.CutCopyMode = False
Selection.Copy
Range("H5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

End Sub



Sub PASTE_UKC_DATA()
'
' PASTE_UKC_DATA Macro
'

'
Sheets("UKC Position List Download").Select
Range("A5:C9").Select
Range("A5:J249").Select
Selection.ClearContents
Sheets("UKC POSITION FORMAT").Select
Range("B5:H33").Select

Range("B5:H221").Select
Selection.Copy
Sheets("UKC Position List Download").Select
Range("D5").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False



'COPY VESSEL AGE, AGE GROUPING AND MONTH OPEN FORMULA TO LAST ROW OF DATA'

Sheets("UKC Position List Download").Select
Dim lastrow As Long
lastrow = Cells(Rows.Count, "D").End(xlUp).Row
Range("A3:C3").Select
Selection.Copy
Range("A5:A" & lastrow).Select
ActiveSheet.Paste




End Sub



Kind regards

Jens Bonde
Microsoft Office Specialist Trainer

Tel: 0207 987 3777
STL - https://www.stl-training.co.uk
98%+ recommend us

London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector

Thu 24 Aug 2023: Automatically marked as resolved.

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Display Formulas Instead of Results in Excel 2010

By pressing Ctrl ~ once, Excel will display formulas rather than the results of the formulas. Press it again, and the results will appear again.

A much quicker and simpler way of displaying your formulas!

View all Excel hints and tips


Server loaded in 0.08 secs.