George J
Well-known Member
- Joined
- Feb 15, 2002
- Messages
- 959
Never been too good at passing variables, but can usually keep it simple enough to get by. Not this time however.
I have a macro that works okay and part of this calls another macro. The second macro passes 2 public variables and this seems to work okay. As part of the second macro however I need to get another variable passed back to the first macro if certain conditions are met on Worksheet_Change. And that is how you tie yourself into a knot.
So the report subroutine runs and calls the SLInc subroutine while passing 2 variables. If the SLInc subroutine results in a specific change to the workbook, blnExport = True. I am trying to pass that value back to the Reports subroutine. I have blnExport set as a Public variable in a module.
Does this make sense?
If anyone can provide inspiration it would be appreciated.
I have a macro that works okay and part of this calls another macro. The second macro passes 2 public variables and this seems to work okay. As part of the second macro however I need to get another variable passed back to the first macro if certain conditions are met on Worksheet_Change. And that is how you tie yourself into a knot.
Code:
Public blnExport as boolean
sub Reports()
'do code, nice and simple
call SLInc(wkbkV, wkbkS)
debug.print blnExport
end sub
Sub SL_Inc(wkbkV As Workbook, wkbkS As Workbook)
'do my code
If CoNm = 5 and Origin > 3 then shtSLI.Range("D65536").end(xlup).value = CoNm.address
'so the worksheet_change event may fire at this stage
end sub
Public Sub Worksheet_Change(ByVal Target As Range)
'do code
blnExport = true
debug.print blnExpoert
end sub
So the report subroutine runs and calls the SLInc subroutine while passing 2 variables. If the SLInc subroutine results in a specific change to the workbook, blnExport = True. I am trying to pass that value back to the Reports subroutine. I have blnExport set as a Public variable in a module.
Does this make sense?
If anyone can provide inspiration it would be appreciated.