I want to call a sub that I've written in another sub, and add a couple new things to it, but use the variables that I've defined in the first sub don't show up in the second, even though the first macro is called within the sub.
For example, I've defined the variables as Public outside of the subs, but the values I define in the first sub, and then call in second sub gets lost. In the code below, running the macro "test" works, but "test1" gives me a "Run-time error '1004'".
Public row1 As Integer
Public col1 As Integer
Sub test()
row1 = 2
col1 = 2
ActiveSheet.Cells(row1, col1).Select
End Sub
Sub test1()
Call test
ActiveSheet.Cells(row1, col1).Resize(6, 5).Select
End Sub
Any guidance on how to get row1 and col1 to work in the test1 sub would be great. Is there a better way to achieve what I'm trying to do?
Dim ws as Worksheet | Set ws = Sheets("Sheet1")and working with that ws.Cells(row1,col1).Resize(6,5).Select`, but since this is probably just test code for the question it's probably not that big of a deal.