Hi all,
I have these multiple VBA subs. See two examples below. I keep changing all my file names (Calculator for All Class 8.12.2021.xlsm) every day (by find and replace) when I run these subs.
Can I declare a global sub name once, and then refer to that name in all my subs and across all modules?
I know my VBA code below is not efficient. I don't know VBA. I would just copy and paste, play around with it to make it work.
I have these multiple VBA subs. See two examples below. I keep changing all my file names (Calculator for All Class 8.12.2021.xlsm) every day (by find and replace) when I run these subs.
Can I declare a global sub name once, and then refer to that name in all my subs and across all modules?
I know my VBA code below is not efficient. I don't know VBA. I would just copy and paste, play around with it to make it work.
VBA Code:
Sub CLASS1_INTL()
Dim MyRange As Range
Windows("1_CLASS_INTL_Daily.csv").Activate
With ActiveSheet.UsedRange
Set MyRange = Range(.Cells(2, 1), .Cells(1, 1).Offset(.Rows.Count - 2, .Columns.Count - 1))
MyRange.Select
Selection.Copy
End With
Windows("Calculator for All Class 8.12.2021.xlsm"). _
Activate
Sheets("CLASS 1 - INTL").Select
Range("A2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Windows("1_CLASS_INTL_Daily.csv").Close
End Sub
Sub CLASS2_INTL()
Dim MyRange As Range
Windows("2_CLASS_INTL_Daily.csv").Activate
With ActiveSheet.UsedRange
Set MyRange = Range(.Cells(2, 1), .Cells(1, 1).Offset(.Rows.Count - 2, .Columns.Count - 1))
MyRange.Select
Selection.Copy
End With
Windows("Calculator for All Class 8.12.2021.xlsm"). _
Activate
Sheets("CLASS 2 - INTL").Select
Range("A2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Windows("2_CLASS_INTL_Daily.csv").Close
End Sub
Last edited by a moderator: