input box accepts date but I can't change to a text entry

beach

New Member
Joined
Feb 1, 2004
Messages
38
The following macro allows the user to enter "date" (e.g. 07/02/04) into cell h29, via an input box, which works perfectly fine

However I expected to be able to use the same general code to get a text entry instead of a date entry, but it won't let me

I want to enter text as the response, (e.g. BILL SMITH), but can't seem to get the syntax right. What do I change ???


Sub ENTERCURRENTYEAR()
'
End Sub
'
' Macro23 Macro
'

'
Sub Using_InputBox_Method()
Dim Response As Date

' Run the Input Box.
Response = Application.InputBox("Enter current Year start date (dd/mm/yy)", _
"FRIDAY REPORT", , 250, 300, "", , 1)

' Check to see if Cancel was pressed.
If Response <> False Then

' If not, write the number to the first cell in the first sheet.
Worksheets(1).Range("h29").Value = Response

End If
End Sub

Any hints appreciated :rolleyes:
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Re: input box accepts date but I can't change to a text entr

How's this?
Code:
Sub Using_InputBox_Method()
    Dim Response As Date
    Dim TextInput As String
    
    ' Run the Input Box.
        Response = Application.InputBox("Enter current Year start date (dd/mm/yy)", _
        "FRIDAY REPORT", , 250, 300, "", , 1)
    
    ' Check to see if Cancel was pressed.
        If Response <> False Then
    
    ' If not, write the number to the first cell in the first sheet.
            Worksheets(1).Range("h29").Value = Response
    
        End If
        
    TextInput = InputBox("Please enter your name", "Name Required")
    Sheets("Sheet1").Range("A1") = TextInput
    
End Sub
Hope that helps,

Smitty
 
Upvote 0
Thanks Smitty - but

I used the following code, and it NEARLY works, but nothing appears in cell A1 of sheet 1


Sub Using_InputBox_Method()
Dim TextInput As String

' Run the Input Box.
TextInput = InputBox("Please enter Client Name", "Name Required", "", , 1)

' Check to see if Cancel was pressed.
If Response <> False Then

' If not, write the number to the first cell in the first sheet.
Sheets("Sheet1").Range("A1") = TextInput

End If

End Sub


What have I missed ?

Ta
 
Upvote 0
Re: input box accepts date but I can't change to a text entr

Code:
Sub Using_InputBox_Method()
    Dim TextInput As String
    
    ' Run the Input Box.
    TextInput = InputBox("Please enter Client Name", "Name Required")
    Sheets("Sheet1").Range("A1") = TextInput

End Sub
Or did you want to require an entry?

Smitty
 
Upvote 0

Forum statistics

Threads
1,203,752
Messages
6,057,152
Members
444,908
Latest member
Jayrey

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top