excel - Passing worksheets to a procedure -


i'm trying pass 3 worksheets procedure call as

call pivot_table(sheets("sheet2"), sheets("sheet3"), sheets("sheet4")) 

but error subscript out of range

also if try as

dim ws, ws1, ws2 worksheet set ws = sheets("sheet2") set ws1 = sheets("sheet3") set ws2 = sheets("sheet4") call pivot_table(ws, ws1, ws2) 

i error byref arguement type mismatch

my procedure is

sub pivot_table(ws1 worksheet, ws2 worksheet, ws3 worksheet) 

not able find appropriate solution. help.

do have sheets named "sheet2", "sheet3", , "sheet4" in workbook? if not, reason subscript out of range error.

the reason byref argument type mismatch declaration of ws, ws1 , ws2 not declaring 3 worksheets.

vba not support kind of multi-variable assignment on 1 line. if want declare on 1 line, still have explicitly declare type of each variable, i.e.

dim ws worksheet, ws1 worksheet, ws2 worksheet 

declaring without type create variant variable, i.e. ws , ws1 : variant, ws2 : worksheet.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -