insert Textbox value in Certain row

Omer_K

Board Regular
Joined
Apr 9, 2017
Messages
124
Office Version
  1. 365
Hello everyone,
I have a table that the first column is the column of a subscription number and all other columns are currently empty,
I have defined that if I double click on one subscriber number, a form will open
Then fill in all the data of the same subscription number (eg first name, family, date of birth, etc.)
the poblem that I would like to know how if I press Finish then all the details from the text boxes will be copied directly to the same line of the same subscription number that I chose


Thank you very much for your help!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
We always need specific details.

1. What column do you plan to double click on. Provide a number like 1 or 5
2. What is the name of the userform form you plan to open
3. What are the names of the textbox's you plan to fill in
4.It's best to name your textboxs the same as their default name.
Like textbox1 textbox2 etc

Then we can loop through their names

So Textbox1 data goes in column 2 textbox2 data goes in column 3 etc.

If you already have some code written then show us your code.

Please be sure and double check and be sure to answer all my questions.
 
Upvote 0
Hey,
This is the Code that i copy form the Internet:



Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
Load SellsPage
With SellsPage
.textbox1.Value = Cells(Target.Row, 1).Value
End With
SellsPage.Show


End Sub

The column that I plan to double click is the coulmn A (Range: A1:A200).
The name of my Userforme is
SellsPage

When I double click on cell A3 for example (cell A3 will be subscription number 5478)
the Userform Sellspage will open and the textbox 1 is already fill with 5478.
In the textbox 2, I will fill the full name
In the textbox 3 I will fill an address
Textbox 4 phone number.
And when I click the finish button (called finish)
Automatic cell B3 will be with the full name
Cell C3 will be with the address
And in cell D3 will be the phone.



Thank You so much...
 
Upvote 0
You need to create a Module script like this:

Code:
Option Explicit
Public r As Long '~~> at the very top of the module outside any sub
Public Sub Anysub()
r = ActiveCell.Row
End Sub


Then put this script in your sheet:

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
Cancel = True
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Call Anysub
Sellspage.Show modeless
Sellspage.TextBox1.Value = Cells(Target.Row, 1).Value
End If
End Sub

Then put this script in your userform:

Code:
Private Sub finish_Click()
Dim i As Long
    For i = 2 To 4
        Cells(r, i).Value = Controls("Textbox" & i).Value
    Next
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,183
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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