Syntax issue

  • Thread starter Thread starter Brett
  • Start date Start date
B

Brett

if "CHECK.REFI" is the name of a cell then how do I pass that to a sub please?

This doesn't work:
Call Q20_DUMPDATA_UF0_QCP("CHECK.REFI")

Sub Q20_DUMPDATA_UF0_QCP(stage)
Set rng = F_LNCH.Range(stage)
....statements
end sub
 
HOLD THE PHONE... I forgot that each of the cell names has ".memory" as a
suffix. The code works.
 
If you are passing the cell address ...that should be as a string like

Call Q20_DUMPDATA_UF0_QCP("A1")

Sub Q20_DUMPDATA_UF0_QCP(stage)
Set rng = F_LNCH.Range(stage)
'...statements
End Sub

but it looks like you are trying to pass a named range

Call Q20_DUMPDATA_UF0_QCP(check.refi)

Sub Q20_DUMPDATA_UF0_QCP(stage as Range)
'...statements
End Sub
 
I suspect that F_LNCH is the sheet object name, not the sheet name. In my
code sample 1 below), and yours, this will raise the Variable Not Defined
error
so rename the object. However, if its the sheet name, then change the code
(sample 2)

sample 1
Option Explicit
Sub x()
Q20_DUMPDATA_UF0_QCP ("CHECK.REFI")
End Sub
Sub Q20_DUMPDATA_UF0_QCP(stage As String)
Dim rng As Range
Set rng = F_LNCH.Range(stage)
End Sub

sample 1
Option Explicit
Sub x()
Q20_DUMPDATA_UF0_QCP ("CHECK.REFI")
End Sub
Sub Q20_DUMPDATA_UF0_QCP(stage As String)
Dim rng As Range
Set rng = Worksheets("F_LNCH").Range(stage)
End Sub
 
Thanks Jacob

Jacob Skaria said:
If you are passing the cell address ...that should be as a string like

Call Q20_DUMPDATA_UF0_QCP("A1")

Sub Q20_DUMPDATA_UF0_QCP(stage)
Set rng = F_LNCH.Range(stage)
'...statements
End Sub

but it looks like you are trying to pass a named range

Call Q20_DUMPDATA_UF0_QCP(check.refi)

Sub Q20_DUMPDATA_UF0_QCP(stage as Range)
'...statements
End Sub
 
Thanks Patrick, sorry I couldn't reply earlier - the website was temporarily
unavailable more than it was spasmodically available. Brett
 
Back
Top