Trying to enter into Text activecell value

Eric Penfold

Active Member
Joined
Nov 19, 2021
Messages
431
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Active cell in column A into a form text code. When I click on a active cell I need it to fill form Textbox. The code below does not work? Click on the cell but nothing happens.

VBA Code:
Private Sub Enter_Number_SheetClick(ByVal Sh As Object, ByVal Target As Range)

    Dim ws     As Worksheet
    Set ws = ActiveSheet
  
    With ws
    If ActiveCell.Column > 1 Then
        Me.Enter_Number = ActiveCell.Value
        End If
    End With
  
End Sub
 
Last edited:

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
By selecting a cell the following procedure is triggered. This goes into the worksheet code module.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

Target is a range object representing the cell selected.

It is into this procedure that you put the code that populates the textbox on the Userform.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

UserForm1.Enter_Number.Value = Target.Value

End Sub

You will need to substitute UserForm1 for your form name.
 
Upvote 0
I have put the code into sheet module code.
When you click into a cell in column A I need that event to fire up the code.
 
Upvote 0
Have you got the userform loaded?

Use this code and a message will pop up to check that it is running.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    MsgBox Target.Value

    UserForm1.Enter_Number.Value = Target.Value

End Sub

You can delete this line later.

MsgBox Target.Value
 
Upvote 0

Forum statistics

Threads
1,223,626
Messages
6,173,415
Members
452,514
Latest member
cjkelly15

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