tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,210
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
Hi Everyone,
I often have macros that use the same commands with in them
Like copy and paste to "Lastrow" having use something like
Now the problem I get is I find I'm repeating a lot of my core code over and over
I was woundering is it possible to stop excel forgeting what I've set lastrow as if I have not ended the sub its in, but simply run another macro within it?
For Example
So my question is can I carry over the last row value t=into a new macro? and how
I often have macros that use the same commands with in them
Like copy and paste to "Lastrow" having use something like
Code:
Lastrow = Sheets("Hours").Cells(Rows.Count, "A").End(xlUp).Row
Now the problem I get is I find I'm repeating a lot of my core code over and over
I was woundering is it possible to stop excel forgeting what I've set lastrow as if I have not ended the sub its in, but simply run another macro within it?
For Example
Code:
Sub Main_Macro()
Lastrow = Sheets("Hours").Cells(Rows.Count, "A").End(xlUp).Row
Call Test1
Range("AA2").PasteSpecial xlPasteValues
Call Test2
Range("BA2").PasteSpecial xlPasteValues
End Sub
Sub Test1()
Range("A2", "B" & Lastrow).Copy
End Sub
Sub Test2()
Range("I2", "K" & Lastrow).Copy
End Sub
So my question is can I carry over the last row value t=into a new macro? and how
Last edited: