Probably an easy one

C

carg1

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

========================
 
N

Nikos Yannacopoulos

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top