ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax issue (https://www.excelbanter.com/excel-programming/428672-syntax-issue.html)

Brett

Syntax issue
 
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

Brett

Syntax issue
 
HOLD THE PHONE... I forgot that each of the cell names has ".memory" as a
suffix. The code works.

"Brett" wrote:

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


Jacob Skaria

Syntax issue
 
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


--
If this post helps click Yes
---------------
Jacob Skaria


"Brett" wrote:

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


Patrick Molloy

Syntax issue
 
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



"Brett" wrote in message
...
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



Brett

Syntax issue
 
Thanks Jacob

"Jacob Skaria" wrote:

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


--
If this post helps click Yes
---------------
Jacob Skaria


"Brett" wrote:

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


Brett

Syntax issue
 
Thanks Patrick, sorry I couldn't reply earlier - the website was temporarily
unavailable more than it was spasmodically available. Brett

"Patrick Molloy" wrote:

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



"Brett" wrote in message
...
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





All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com