ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Probably an easy one (https://www.excelbanter.com/excel-programming/314262-probably-easy-one.html)

carg1[_3_]

Probably an easy one
 

Hi, I'm thinking this probably a simple problem, but being a novice it'
eluding me. I have two macros, the first (GetInput()) brings up a
input box into which I enter a date. In the next one (Dte()), I wante
to take the date that was in the variable from GetInput so I could plu
it in the sheet. I didn't want to merge the two because I don't wan
the input box to come up everytime I run the macro. I just want to b
able to get the input box whenever I want to change the date in Dte.
thought that making both public and GetInput public and static woul
work, but it didn't, it gives me no output at all. Can anybody help?

=========================

Public Static Sub GetInput()

Dim MyInput
MyInput = InputBox("Enter Date")
End Sub

=========================

Public Sub Dte()

Dim Dte
Dte = MyInput
Selection.Offset(0, 19) = Dte

End Sub

========================

--
carg
-----------------------------------------------------------------------
carg1's Profile: http://www.excelforum.com/member.php...fo&userid=1527
View this thread: http://www.excelforum.com/showthread.php?threadid=27115


Nikos Yannacopoulos[_5_]

Probably an easy one
 
Indeed an easy one. You need to use a public variable to store the inputted
date value:

Public MyInput
'at the top of the module, before the first Sub or Function

Public Sub GetInput()
MyInput = InputBox("Enter Date")
End Sub

Public Sub Dte()
Selection.Offset(0, 19).Value = MyInput
End Sub

HTH,
Nikos

"carg1" wrote in message
...

Hi, I'm thinking this probably a simple problem, but being a novice it's
eluding me. I have two macros, the first (GetInput()) brings up an
input box into which I enter a date. In the next one (Dte()), I wanted
to take the date that was in the variable from GetInput so I could plug
it in the sheet. I didn't want to merge the two because I don't want
the input box to come up everytime I run the macro. I just want to be
able to get the input box whenever I want to change the date in Dte. I
thought that making both public and GetInput public and static would
work, but it didn't, it gives me no output at all. Can anybody help?

=========================

Public Static Sub GetInput()

Dim MyInput
MyInput = InputBox("Enter Date")
End Sub

=========================

Public Sub Dte()

Dim Dte
Dte = MyInput
Selection.Offset(0, 19) = Dte

End Sub

=========================


--
carg1
------------------------------------------------------------------------
carg1's Profile:

http://www.excelforum.com/member.php...o&userid=15271
View this thread: http://www.excelforum.com/showthread...hreadid=271155





All times are GMT +1. The time now is 07:00 PM.

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