Pass function sheet (excel vba)

I am trying to pass a sheet in my function book, but it does not seem to work. Function

Private Sub passToSheet(theData As Variant, Optional mySheet As Worksheet) 

I tried to do

 Dim mySheet as Worksheet Set mySheet = "Results" 

then to call the function

 passToSheet theData mySheet 

but it does not seem to work. I'm not quite sure what to do with Google to get the correct way to link to a worksheet! Any help is much appreciated!

+4
source share
1 answer

Use

 'Set mySheet to worksheet Set mySheet = Worksheets("Results") 

to get a link to the worksheet.

+6
source

All Articles