stonysleep
New Member
- Joined
- Feb 2, 2011
- Messages
- 10
I'm doing something which is probably foolish - namely taking some vba that i've written that works and trying to make it more technically correct by using subroutines.
It doesn't need it as it is fast enough as it is but i'm a perfectionist and if it ain't broke don't fix it is about to become if it ain't broke it will be after i've messed about with it!
Anyway, i'm not very good with subroutines and coming a cropper when it comes to parsing variables from 1 sub into another.
What I am trying to do is call a sub routine from another and parse 3 variables but i keep getting an error message:
"Compile error ByRef argument type mismatch"
This works:
This doesn't:
In actual fact the variables flag, flagref and newname are cell references but since it doesn't even work when setting the variables to a, b and c i must be doing something fundamentally wrong.
I tried changing ByVal in the called procedure to ByRef but that didn't change anything - same error message
Any help much appreciated
Thanks
It doesn't need it as it is fast enough as it is but i'm a perfectionist and if it ain't broke don't fix it is about to become if it ain't broke it will be after i've messed about with it!
Anyway, i'm not very good with subroutines and coming a cropper when it comes to parsing variables from 1 sub into another.
What I am trying to do is call a sub routine from another and parse 3 variables but i keep getting an error message:
"Compile error ByRef argument type mismatch"
This works:
Code:
sub test()
Call drill("a", "b", "c")
end sub
Sub drill(ByVal job As String, flagname As String, sheetname As String)
Debug.Print job & " " & name & " " & sheetname
...lots of code
end sub
This doesn't:
Code:
Sub test()
flag = "a"
flagref = "b"
newname = "c"
Call drill(flag, flagref, newname)
End Sub
Sub drill(ByVal job As String, flagname As String, sheetname As String)
Debug.Print job & " " & name & " " & sheetname
...lots of code
end sub
In actual fact the variables flag, flagref and newname are cell references but since it doesn't even work when setting the variables to a, b and c i must be doing something fundamentally wrong.
I tried changing ByVal in the called procedure to ByRef but that didn't change anything - same error message
Any help much appreciated
Thanks