Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error pasing arguments in Excel 2

Status
Not open for further replies.

ChrisBurch

IS-IT--Management
Jul 3, 2001
184
AU
Excel 97.

I have a funtion that takes 1 argument (integer), and works fine. I am trying to expand it, and need to pass the sheet name to it. I have added the extra arg to the function okay, but when I add it to the sub to pass I get a compiler error telling me that the compiler was "expecting: = ".

I can pass the sheet name to a test function okay as a single arg, the the second arg bodgies me every time. Can/will someone tell what I am dong wrong?

Private Sub CmdBtnWebData_Click()
Dim Last_Row As Integer
Dim WsName As String
WsName = ActiveSheet.name
Last_Row = FindLastRow()
CopyDataRange (Last_Row, WsName) Error here

Thanks,

End Sub

Chris

It worked yesterday.
It doesn't work today.
That's Windows!
 
issue a call if copydatarange is defined as a sub.

e.g.
call copydatarange (last_row, wsname)

If defined as a function then you need to assign a variable to it.

newvar = copydatarange(last_row, wsname)


Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Thanks Frederico, I think I've swallowed too many idiot pills lately :) I'm not actually returning anything from the function, so the code couldn't get back to the sub.

For now I've changed the sub to call the function, and it's working okay. But I guess I should actually put some error testing in the function, and return the error code.

Chris

It worked yesterday.
It doesn't work today.
That's Windows!
 

Alternatively, you can just omit the parentheses alltogether:
Code:
   copydatarange last_row, wsname
or
Code:
  copydatarange RowNumber:=last_row, SheetName:=wsname
if (for example) RowNumber and SheetName are the argument names specified in the sub definition.

 
Thanks Zathras, I learnt something else :)

Chris

It worked yesterday.
It doesn't work today.
That's Windows!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top