Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros and vba
To invoke vba with a worksheet do you place the code inside the macro and
call it? If so how would you do that? I want to code a form and I am having trouble figuring out how to run it. I know how to record a macro and run it but not the vba and run it. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros and vba
Hi
This link might answer most of your questions http://www.danielklann.com/tutorials/tutorial_index.htm Do well N10 "lschuh" wrote in message ... To invoke vba with a worksheet do you place the code inside the macro and call it? If so how would you do that? I want to code a form and I am having trouble figuring out how to run it. I know how to record a macro and run it but not the vba and run it. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macros and vba
You can assign a program to a macro button, run macro dialogue etc so long as the scope of the procedure is public and you do not include any arguments in your procedure statement. So...in the VBA editor, insert a module and start writing some code. This code snippet is a form that loads listboxes with an item list. User selects one or more items from the list box and then hits a command button that pastes list into some destination, like a work sheet's cell range or another form's text box. If user does not select anything, a msgbox appears warning user to select something. Module level code Option Explicit Private m_shtMySheet As Worksheet Private m_objOP As classOutPutDestination Public Sub Test() ' This is your form and loads it formAutoXItemFinderA.Show ' Sets reference to form's object reference (see below) Set m_objOP = formAutoXItemFinderA.OPReference ' When you activate some event (see "cmndPasteSelection_Click" below) include "formAutoXItemFinderA.Hide" statement in control's event trigger. ' That will bring you back to this Sub where some more code execution takes place and then the unload form is invoked that closes the form. Unload formAutoXItemFinderA Set m_shtMySheet = Workbooks("Zook1.xls").Sheets("ScratchPad") m_objOP.Write_SelectedItemList m_shtMySheet.Range("A1") Set m_objOP = Nothing End Sub Form level code Private Sub cmndPasteSelection_Click() ' Out put route for final item list Set m_objOutPut = New classOutPutDestination m_varOP = AssignOPList If Not m_blErrorHandlingInvoked Then m_objOutPut.SelectedOPItemList = m_varOP formAutoXItemFinderA.Hide Exit Sub Else: Msg_NoSelection End If End Sub -- 3c "lschuh" wrote: To invoke vba with a worksheet do you place the code inside the macro and call it? If so how would you do that? I want to code a form and I am having trouble figuring out how to run it. I know how to record a macro and run it but not the vba and run it. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
choose default macros Not Enabled / Macros Enable Setting | Excel Programming | |||
weird saving of a document with macros resulting with macros being transfered to the copy | Excel Programming | |||
Macros inside macros, and pasting into macro code. | Excel Programming | |||
Macros not appearing in the Tools Macro Macros list | Excel Programming | |||
Suppress the Disable Macros / Enable Macros Dialog | Excel Programming |