LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
David
 
Posts: n/a
Default

Bob

Thanks for your patience. Just wanted to let you know that your help has
resolved my problem - very much appreciated.

David

"Bob Phillips" wrote in message
...
I repeat

... Create public variables store them in the macro module in the
declarations, before the macro ...

the variable should be defined before the macro not within it when you
make
it public.

To load them in the form just means assign a value to that variable.

MODULE


Public myVar as String

Sub Macro1()

Msgbox myVar

End Sub

FORM


Private Sub CommandButton1_Click()
myVar = "testing"
Unload Me
End Sub


--
HTH

Bob Phillips

"David" wrote in message
...
Thank you for your response. I'm being a bit thick here and need to ask

what
may be obvious. I used the word Public instead of Dim at the beginning of
the macro, where I declare the variables but get 'Invalid attribte in Sub

or
Function'. I'm not sure how to create public variables in the macro and

how
to load them from within the form. I have a simple form with Initialise

and
Click subroutines. I'm trying to gather data from the form to use in the
macro.

Thanks
David

"Bob Phillips" wrote in message
...
Create public variables store them in the macro module in the
declarations,
before the macro, and load them from within the form.

--
HTH

Bob Phillips

"David" wrote in message
...
Hi

I have a working Excel VBA macro and would like to use a form for all

the
inputs. I have the form and the code behind the text/combo boxes etc.
I
just
don't know how to call the form so that the data collected is passed
to
the
variables in the main macro. I searched for this information but can

only
find info on creating the form rather than having it run with a macro.
I'd
appreciate any info, links etc. It would be great if you could point
me
to
an example form with all the suurounding code, declarations etc. Can

the
form be used for the output of the macro?

Thanks
David












 
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
Passing variables between a form and macro David New Users to Excel 1 October 5th 05 04:42 AM
Display form from an VB application in Excel kuhni Excel Discussion (Misc queries) 0 August 10th 05 06:04 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
2 part question - macro / command button John Excel Discussion (Misc queries) 3 April 16th 05 09:00 PM
Attaching a macro to a VB button on a form WildGlio Excel Worksheet Functions 2 March 25th 05 11:11 PM


All times are GMT +1. The time now is 06:43 AM.

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

About Us

"It's about Microsoft Excel"