Clicking on cell to go to VBA user form

VBAmalta89

Board Regular
Joined
Mar 25, 2011
Messages
116
i have created a VBA user form which will send the data inputted in it to a worksheet on excel.

Is it possible to use VBA so that when the user needs to edit the data all he needs to do is click on any cell in the worksheet that contains data from the user form?

I am new to VBA so Im sort of clueless :laugh:
 

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
You could capture a selection change, right-click or double-click on cells using a worksheet event, then populate the userform with the data that the clicked on row contained.

Put the following code on the codepage of the worksheet that should be monitored:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim rngDataRange As Range
 
    Set rngDataRange = Range("A1:F500") 'Enter range(s) that should be monitored
 
    If Target.Cells.Count > 1 Then GoTo End_Sub 'ensure only 1 cell
    If Not Intersect(Target, rngDataRange) Is Nothing Then
        Application.EnableEvents = False 'Prevent following code from triggering events
        'Code to do what is desired when
        Debug.Print Target.Row, Target.Address 'for debug & demo
    End If
End_Sub:
    Set rngDataRange = Nothing
    Application.EnableEvents = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,673
Members
452,937
Latest member
Bhg1984

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