Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default 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   Report Post  
Posted to microsoft.public.excel.programming
N10 N10 is offline
external usenet poster
 
Posts: 141
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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
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
choose default macros Not Enabled / Macros Enable Setting BEEJAY Excel Programming 2 June 30th 06 01:07 PM
weird saving of a document with macros resulting with macros being transfered to the copy alfonso gonzales Excel Programming 0 December 12th 04 09:19 PM
Macros inside macros, and pasting into macro code. pagelocator[_2_] Excel Programming 1 November 24th 04 09:11 AM
Macros not appearing in the Tools Macro Macros list hglamy[_2_] Excel Programming 5 October 24th 03 09:10 AM
Suppress the Disable Macros / Enable Macros Dialog Shoji Karai Excel Programming 5 September 24th 03 03:10 AM


All times are GMT +1. The time now is 04:30 PM.

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"