Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 390
Default How do I initiate a Visual Basic Module in Excel?

I've created macros with Excel (or Visual Basic?) recording keystrokes/mouse
clicks, but I've never interacted with VB directly.

I want to add a time / date stamp in a worksheet that will change each time
I save a workbook.

Not even sure where to begin.
--
Thanks,Bill
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 298
Default How do I initiate a Visual Basic Module in Excel?

To get to the Visual Basic Editor go to the Tools Menu/Macro/Visual Basic
Editor (or press Alt F11). Inside the Visual Basic Editor go to the Insert
Menu and select Module. This will add a code module to your workbook. In
the code module you can start a visual basic sub routine by typing code like
the following (or just copy and past this code):

Sub SetFooterHeaders()
Dim sht As WorkSheet

For Each sht In ThisWorkBook.Sheets
sht.PageSetup.CenterHeader = sht.Name
sht.PageSetup.RightFooter = "Run Date: " & Date
Next

End Sub

Now, when you go back to the worksheet, click on Tools/Macro/Macros and you
will see your subroutine "SetFooterHeaders" listed in the Macros list.
Select your macro and click on the Run button. The macro above will iterated
(loop) through all the sheets in your workbook and add the sheet name to the
respective sheet header and Today's Date as the footer. Date is a built-in
Visual Basic function that returns Today's Date. You can now go into the
PrintPreview screen and see your Headers and footers for each sheet. Note:
you could also run the code above from the Visual Basic Editor by placing the
mouse cursor anywhere inside the subroutine and pressing the F5 key.

Rich

"Bill" wrote:

I've created macros with Excel (or Visual Basic?) recording keystrokes/mouse
clicks, but I've never interacted with VB directly.

I want to add a time / date stamp in a worksheet that will change each time
I save a workbook.

Not even sure where to begin.
--
Thanks,Bill

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default How do I initiate a Visual Basic Module in Excel?

Bill,

You are entering the realm of events, and you are not yet properly ordained
:-).

Have a look at Chip's site for some pointers
http://www.cpearson.com/excel/events.htm

--
HTH

Bob Phillips

"Bill" wrote in message
...
I've created macros with Excel (or Visual Basic?) recording

keystrokes/mouse
clicks, but I've never interacted with VB directly.

I want to add a time / date stamp in a worksheet that will change each

time
I save a workbook.

Not even sure where to begin.
--
Thanks,Bill



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 82
Default How do I initiate a Visual Basic Module in Excel?

Bob,
I realize your initial post to Bill's question was many years ago, but I'd
like to say that I am very greatful to you and all the contributors out there
as well as the moderators of the Microsoft Discussion Groups! And just why
am I so happy, well I find myself in Bill's shoes at this point in having a
need to learn how to initiate a VB module within Excel 2003. I've posted a
few questions over the last two months or so and just recently one regarding
the use of a Drop-Down Combo box. I have no clue as to how to do this, but .
.. .

Your suggestion to view Chip's website just may be what I need to get
started, I thank you and the site moderators for keeping posts like this one
available over the years!

Mike

"Bob Phillips" wrote:

Bill,

You are entering the realm of events, and you are not yet properly ordained
:-).

Have a look at Chip's site for some pointers
http://www.cpearson.com/excel/events.htm

--
HTH

Bob Phillips

"Bill" wrote in message
...
I've created macros with Excel (or Visual Basic?) recording

keystrokes/mouse
clicks, but I've never interacted with VB directly.

I want to add a time / date stamp in a worksheet that will change each

time
I save a workbook.

Not even sure where to begin.
--
Thanks,Bill




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
microsoft visual basic-compile error in hidden module:modMain Roman Piotr Excel Discussion (Misc queries) 3 January 23rd 13 01:49 PM
Imported Visual Basic Module - Save Macros for use in Excel Pat Adams Excel Discussion (Misc queries) 1 December 2nd 09 09:44 PM
Visual Basic module from Excel 2003 crashing in Excel 2007 Chuck Angier Excel Discussion (Misc queries) 0 December 4th 07 01:42 AM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
exel : visual basic: compile error in hidden module : Distmon cde01 Excel Discussion (Misc queries) 1 July 26th 05 01:15 PM


All times are GMT +1. The time now is 12:45 PM.

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"