scottleger4
New Member
- Joined
- Oct 3, 2016
- Messages
- 41
- Office Version
- 365
- Platform
- Windows
I'm having trouble with dimensioning variables to be used across multiple subs. I'm trying to keep the length of the individual subs as short as possible, and currently the only working version requires me to run the dims in every sub. In its simplest form...
Sub Master
RunSub1
RunSub2
End Sub
Sub RunSub1
Dim Variable1 As String
Dim Variable1Entry as Range
Set Variable1Entry = Sheet.Range("A1")
End Sub
Sub RunSub2
Do Until Variable1Entry.Value = ""
...
...
...
Set Variable1Entry = Variable1Entry.Offset(1, 0)
Loop
End Sub
Everything seems to work fine until VBA jumps to the "Do Until" and then debugs saying "Object Required" which I assume means the previous dim I did for that value isn't 'sticking.' There are currently about 30 variables I need to use, so copying those to the start of every sub would make my code REALLY long. I'm sure it is something pretty simple that I just can't come up with. Thoughts? Thanks in advance.
Sub Master
RunSub1
RunSub2
End Sub
Sub RunSub1
Dim Variable1 As String
Dim Variable1Entry as Range
Set Variable1Entry = Sheet.Range("A1")
End Sub
Sub RunSub2
Do Until Variable1Entry.Value = ""
...
...
...
Set Variable1Entry = Variable1Entry.Offset(1, 0)
Loop
End Sub
Everything seems to work fine until VBA jumps to the "Do Until" and then debugs saying "Object Required" which I assume means the previous dim I did for that value isn't 'sticking.' There are currently about 30 variables I need to use, so copying those to the start of every sub would make my code REALLY long. I'm sure it is something pretty simple that I just can't come up with. Thoughts? Thanks in advance.