ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automatically running an Excel macro on open once only (https://www.excelbanter.com/excel-programming/399909-automatically-running-excel-macro-open-once-only.html)

David Andrews[_2_]

Automatically running an Excel macro on open once only
 

Hi guys,

Does anyone know of a way to automatically run a macro on open once
only? i.e. A user opens an excel worksheet, a macro is run prompting
them for some information, they save the file, re-open it however this
time it does not prompt for the questions? Please see below for my
macro. Any help would be greatly appreciated.


Sub Project()

Dim inputvar As String
Dim inputvar2 As String
Dim inputvar3 As String

inputvar = InputBox("Please Enter the Project Name?")
Range("b1") = inputvar

inputvar2 = InputBox("Please Enter the Start Date")
Range("b7") = inputvar2

inputvar3 = InputBox("Please Enter the Location")
Range("b8") = inputvar3

End Sub

*** Sent via Developersdex http://www.developersdex.com ***

Carlo

Automatically running an Excel macro on open once only
 
Hi David

do you have a possibility to set a flag somewhere?
Like on an unused hidden sheet in A1.

Let's say you make a sheet "settings" and hide it.

on open you do:

if worksheets("settings").range("a1").value = "" then
call project
worksheets("settings").range("a1").value = "Used"
end if

hth

Carlo


"David Andrews" wrote:


Hi guys,

Does anyone know of a way to automatically run a macro on open once
only? i.e. A user opens an excel worksheet, a macro is run prompting
them for some information, they save the file, re-open it however this
time it does not prompt for the questions? Please see below for my
macro. Any help would be greatly appreciated.


Sub Project()

Dim inputvar As String
Dim inputvar2 As String
Dim inputvar3 As String

inputvar = InputBox("Please Enter the Project Name?")
Range("b1") = inputvar

inputvar2 = InputBox("Please Enter the Start Date")
Range("b7") = inputvar2

inputvar3 = InputBox("Please Enter the Location")
Range("b8") = inputvar3

End Sub

*** Sent via Developersdex http://www.developersdex.com ***


OssieMac

Automatically running an Excel macro on open once only
 
This has been posted twice. See my reply on the other post.

Regards,

OssieMac

"David Andrews" wrote:


Hi guys,

Does anyone know of a way to automatically run a macro on open once
only? i.e. A user opens an excel worksheet, a macro is run prompting
them for some information, they save the file, re-open it however this
time it does not prompt for the questions? Please see below for my
macro. Any help would be greatly appreciated.


Sub Project()

Dim inputvar As String
Dim inputvar2 As String
Dim inputvar3 As String

inputvar = InputBox("Please Enter the Project Name?")
Range("b1") = inputvar

inputvar2 = InputBox("Please Enter the Start Date")
Range("b7") = inputvar2

inputvar3 = InputBox("Please Enter the Location")
Range("b8") = inputvar3

End Sub

*** Sent via Developersdex http://www.developersdex.com ***



All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com