VBA input box on clicking cell

apkdsmith

New Member
Joined
Aug 29, 2013
Messages
8
I'm sure this question must have been asked somewhere, but I haven't been able to find it.

Is it possible to bring up an input box in VBA by clicking on a cell or its contents? Like a hyperlink sort of thing? Ideally, I don't want to have to introduce a button, as I would like to be able to do this for each cell in a list, so that the contents of the input box varies depending on the cell clicked on.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi,

Here you go: -

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    If Target.Address = "$B$1" Then
        ShowForm
    End If
    
End Sub

Sub ShowForm()

    UserForm1.Show
    
End Sub

Regards
 
Upvote 0
Thanks. Can you explain how this works, please? I think I need to be able to understand it to implement it correctly? Also, does it just go in the relevant sheet?
 
Upvote 0
Hi,

The above is for a sheet, I had it against Sheet1.

It then monitors if the Selection on the Active Sheet (Sheet1) changes, if it does it checks the 'Target' of the change, in this case it checks to see if it's B1. If this is the case it then calls the other Sub Routine which in turn shows the form.

Yes, that code is for the relevant sheet.

Regards
 
Upvote 0

Forum statistics

Threads
1,216,079
Messages
6,128,687
Members
449,464
Latest member
againofsoul

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