Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default How do I call VBA subs from different spreadsheet from code behind form?

Inherited existing application, VBA validation subs are trigger from
Worksheet_Change and/or Workbook_SheetSelectionChange. Change subs call
subs from separate worksheet which error when called from Code Behide Form.

Form added to allow user input into multiple spreadsheets.

How do I call VBA subs from different spreadsheet from code behind form?

clhamilton


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default How do I call VBA subs from different spreadsheet from code behindform?

I'm not sure if this is what you mean, but you can use application.run to call
procedures in other workbook projects.

Saved from a post for a similar question:

Dim pWkbk as workbook
set pwkbk = workbooks("Personal.xls")
application.run "'" & pwkb.name & "'!macronamehere", "parm1", "parm2"

or if you're returning a value from a function:

dim res as string 'or variant or long or ...
res = application.run("'" & pwkb.name & "'!macronamehere", "parm1", "parm2")

You could also create a reference to this personal.xls workbook and call it just
like it was built into excel.

Tools|references
(but give the personal.xls's project a nice unique name (not VBAProject).

ps.

If you're using a function living in personal.xls inside a cell:
=personal.xls!functionnamehere(a1,b1,c1)

or save the file as an addin (*.xla) and use it in the cell like it's built into
excel:
=functionnamehere(a1,b1,c1)




clhamilton wrote:

Inherited existing application, VBA validation subs are trigger from
Worksheet_Change and/or Workbook_SheetSelectionChange. Change subs call
subs from separate worksheet which error when called from Code Behide Form.

Form added to allow user input into multiple spreadsheets.

How do I call VBA subs from different spreadsheet from code behind form?

clhamilton


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel code to call a macro when a certain value in a cell isselected. [email protected] Excel Worksheet Functions 4 February 15th 08 09:18 PM
Can you call a Web Service from Excel 2007 without writing code? BigBadBubba Excel Discussion (Misc queries) 0 March 14th 07 04:32 AM
how can i call sub or function in vba code xxx Excel Discussion (Misc queries) 3 June 28th 06 11:47 AM
How Can I call any form or macro.. Victor Excel Worksheet Functions 1 November 16th 05 09:42 AM
How can I call a macro or form. in the moment that enable any shee Victor Excel Worksheet Functions 1 November 16th 05 09:42 AM


All times are GMT +1. The time now is 12:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"