Adding VB code to a worksheet

  • Thread starter Thread starter Jake8
  • Start date Start date
J

Jake8

How does one insert some VB code into a worksheet so that when the
worksheet is opened the code automatically runs eg cells are updated
continuously and automatically?
 
Jake8,

You don't "insert" VB code into a worksheet.
You write it in a module or record it.
Once that's done, if you want "that" code to run whenever you
open the workbook, you can rename the module to Auto_Open
or "call" your macro from an Auto_Open sub.

example:

Sub Auto_Open()
Macro1 ' macro that you want to run when the WB opens
End Sub

John
 
You might also want to check out the OnTime method which will run a proc at
a stated time (and so can be repeated). Check out the OnTime method in VBA
Help, and see Chip's page at
http://www.cpearson.com/excel/ontime.htm

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

John Wilson said:
Jake8,

You don't "insert" VB code into a worksheet.
You write it in a module or record it.
Once that's done, if you want "that" code to run whenever you
open the workbook, you can rename the module to Auto_Open
or "call" your macro from an Auto_Open sub.

example:

Sub Auto_Open()
Macro1 ' macro that you want to run when the WB opens
End Sub

John
 
Back
Top