Input Message in Cell via input box

Senthil Murugan

New Member
Joined
Sep 25, 2024
Messages
47
Office Version
  1. 365
Platform
  1. Windows
Good Morning Everybody

Can anybody help to correct the below code?

I need to get Title and Input Message in Cell via input box

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
On Error GoTo None
With Range("A15").Validation
InputTitle = InputBox("Title", "Enter your Title")
InputMessage = InputBox("File Name", "Enter Your File Name")
End With
Application.ScreenUpdating = True
None:
On Error GoTo 0
End Sub




Thanks


A.Senthil Murugan
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Can you show us an actual example of what you want the final cell to look like?
And how does it know which cell to place the result in?
 
Upvote 0
Dear Sir,

Thank you Mr.Joe for your reply

I need to put data validation input message ( Title and input message ) through input box instead of manual through in-built Data validation menu

in A15, Validation input message

1st input box text is " Folder A"
2nd Input box text is "File : Purchase Bills" as shown in the below screenshot

1731417283121.png



Where i am making mistake in my code ?

Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
On Error GoTo None
With Range("A15").Validation
InputTitle = InputBox("Title", "Enter your Title")
InputMessage = InputBox("File Name", "Enter Your File Name")
End With
Application.ScreenUpdating = True
None:
On Error GoTo 0
End Sub


Thanks in advance


A.Senthil Murugan
 
Upvote 0
Firstly, when posting VBA code, please use Code Tags, as described here. It makes your code much easier to read, and much easier to spot errors.
Also note that all properties located between "With" and "End With" need to be preceded by a period to show that the below to the object of your WITH clause.

This code should do what you want:
VBA Code:
Private Sub CommandButton1_Click()

    Dim tl As String
    Dim msg As String

    Application.ScreenUpdating = False

'   Prompt for title and message
    tl = InputBox("Title", "Enter your Title")
    msg = InputBox("File Name", "Enter Your File Name")

    On Error GoTo None
    With Range("A15").Validation
        .Delete
        .Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
        :=xlBetween
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = tl
        .ErrorTitle = ""
        .InputMessage = msg
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With

    Application.ScreenUpdating = True

None:
    On Error GoTo 0
    
End Sub
 
Upvote 1
Solution
Vba export
Firstly, when posting VBA code, please use Code Tags, as described here. It makes your code much easier to read, and much easier to spot errors.
Also note that all properties located between "With" and "End With" need to be preceded by a period to show that the below to the object of your WITH clause.

This code should do what you want:
VBA Code:
Private Sub CommandButton1_Click()

    Dim tl As String
    Dim msg As String

    Application.ScreenUpdating = False

'   Prompt for title and message
    tl = InputBox("Title", "Enter your Title")
    msg = InputBox("File Name", "Enter Your File Name")

    On Error GoTo None
    With Range("A15").Validation
        .Delete
        .Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
        :=xlBetween
        .IgnoreBlank = True
        .InCellDropdown = True
        .InputTitle = tl
        .ErrorTitle = ""
        .InputMessage = msg
        .ErrorMessage = ""
        .ShowInput = True
        .ShowError = True
    End With

    Application.ScreenUpdating = True

None:
    On Error GoTo 0
  
End Sub
Input Message in cell via Inputbox
 
Upvote 0
You are welcome.
Glad I was able to help!
 
Upvote 0

Forum statistics

Threads
1,224,620
Messages
6,179,928
Members
452,949
Latest member
beartooth91

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