Value from Textbox on Userform to Cell on Sheet

MichelVBA

New Member
Joined
Mar 28, 2025
Messages
10
Office Version
  1. 365
Platform
  1. Windows
I have build a userform with 3 tabs (see fig.2). On the whole userform are several textboxes that's connected with cells on a sheet (see fig.1)
In specialy one textbox (see fig. 3), the value will not not save to the sheet. Fig.3 in the next post.
The properties of the textbox is the setting "MultiLine" on True.
I am an newbe with VBA, and im sure i meshed up with the code and the file is so large that the code reaches to Rome.
Afb1.jpg
Afb2.jpg
 
I found the problem. The cells are blocked when the code below is activated.
This means that the value cannot be copied or modified and saved.
Does anyone know a code that undoes the selection once the userform has loaded.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range("A2:IA1000")) Is Nothing Then
If Target.Address = Target.EntireRow.Address Then
frmForm9.txtProjnr = Cells(Target.Row, 2)
frmForm9.Show
End If
End If
End Sub
 
Upvote 0
If your userform is modal then use Application.EnableEvents=False in the UserForm_Activate code and Application.EnableEvents=False in the UserForm_Deactivate code.
This will prevent event driven code from running while you are entering the date in the the userform and transferring it to the sheet.
 
Upvote 0
Ok thanks, but this is beyond my capabilities. Unfortunately I have too little knowledge of VBA to understand this right away.
Userform_Activate code??
My userform starts as soon as a line number is selected.
Or, after this problem arose, via a separate button.
 
Upvote 0
In the VBA Project Explorer you'll find similar to the image which will help with where you'd put the code.
 

Attachments

  • Temp.png
    Temp.png
    38.1 KB · Views: 7
Upvote 0
Dear @Teeroy
Somehow this doesn't work for me.
The selected line remains active after the userform appears, which means the changes are not saved.
 
Upvote 0

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