How to copy values from multiple cells into another textbox.

Thrizian

New Member
Joined
Jul 18, 2012
Messages
27
I'm so proud of how i managed to get my first VBA project working. Yet there is one thing that's missing:

I would like to know how i can get the data entered in the cells to the left actively show in the textbox to the right.

Because i want to make a standard solution that can be copy pasted from the text field easily.

Screenshot of current VBA project. Hoping it clarifies my question.
o732y.png
 
Last edited:
Try someting like this...

Code:
txbRight.Value = "Called customer " & txbKlantnummer.Value & " for validating information. " & vbLf & _
                 txbVoorleters.Value & " " & txbTussenvoegsel.Value & " " & txbAchternaam.Value & "."
 
Upvote 0
I am beyond grateful once again! It's great to know people share their knowledge, One silly question i need not to ask anymore :)

Now lets see if this works.
 
Upvote 0
You're welcome.

Your next question may be; how to put literal quotes as part of the text in the textbox. In the VBA code, each literal quote within a text string is represented by two quotes e.g.

Code:
txbRight.Value = "This is quoted ""text"" within the string."

In this case, the word "text" will have quotes around it.
 
Upvote 0
I added the code, yet it's not showing. Should i add this code to the text field or a command button?

Code:
Option Explicit

Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("OBN")

'find first empty row in database
iRow = ws.Range("A:AI").Find(What:="*", SearchOrder:=xlRows, _
       SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1

'check for a part number
If Trim(Me.tklantnummer.Value) = "" Then
  Me.tklantnummer.SetFocus
  MsgBox "Voer a.u.b. de gegevens in"
  Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.tklantnummer.Value
ws.Cells(iRow, 2).Value = Me.tvoorletters.Value
ws.Cells(iRow, 3).Value = Me.ttussenvoegsel.Value
ws.Cells(iRow, 4).Value = Me.tachternaam.Value
ws.Cells(iRow, 5).Value = Me.tstraat.Value
ws.Cells(iRow, 6).Value = Me.thuisnummer.Value
ws.Cells(iRow, 7).Value = Me.tpostcode.Value
ws.Cells(iRow, 8).Value = Me.tplaats.Value
ws.Cells(iRow, 9).Value = Me.combihuidigi.Value
ws.Cells(iRow, 10).Value = Me.tnaamhuidigi.Value
ws.Cells(iRow, 11).Value = Me.tklnrhuidigi.Value
ws.Cells(iRow, 12).Value = Me.combihuidigtv.Value
ws.Cells(iRow, 13).Value = Me.tnaamhuidigtv.Value
ws.Cells(iRow, 14).Value = Me.tklnrhuidigtv.Value
ws.Cells(iRow, 15).Value = Me.Combihuidigp.Value
ws.Cells(iRow, 16).Value = Me.tnaamhuidigp.Value
ws.Cells(iRow, 17).Value = Me.tklnrhuidigp.Value
ws.Cells(iRow, 18).Value = Me.datumact.Value
ws.Cells(iRow, 19).Value = Me.teindi.Value
ws.Cells(iRow, 20).Value = Me.teindtv.Value
ws.Cells(iRow, 21).Value = Me.teindp.Value
ws.Cells(iRow, 22).Value = Me.oact.Value
ws.Cells(iRow, 23).Value = Me.optOBN.Value
ws.Cells(iRow, 24).Value = Me.optON.Value
ws.Cells(iRow, 25).Value = Me.nummerbehoud.Value

'clear the data
Me.tklantnummer.Value = ""
Me.tvoorletters.Value = ""
Me.ttussenvoegsel.Value = ""
Me.tachternaam.Value = ""
Me.tstraat.Value = ""
Me.thuisnummer.Value = ""
Me.tpostcode.Value = ""
Me.tplaats.Value = ""
Me.combihuidigi.Value = ""
Me.tnaamhuidigi.Value = ""
Me.tklnrhuidigi.Value = ""
Me.combihuidigtv.Value = ""
Me.tnaamhuidigtv.Value = ""
Me.tklnrhuidigtv.Value = ""
Me.Combihuidigp.Value = ""
Me.tnaamhuidigp.Value = ""
Me.tklnrhuidigp.Value = ""
Me.datumact.Value = ""
Me.teindi.Value = ""
Me.teindtv.Value = ""
Me.teindp.Value = ""
Me.oact.Value = ""
Me.optOBN.Value = ""
Me.optON.Value = ""
Me.nummerbehoud.Value = ""
Me.tklantnummer.SetFocus

End Sub

Private Sub cmdClose_Click()
Unload Me
End Sub

Private Sub topdesk_Change()
topdesk.Value = "Called customer & tklantnummer.Value & for validating information. " & vbLf & _
                 txbVoorleters.Value & " " & txbTussenvoegsel.Value & " " & txbAchternaam.Value & "."
End Sub

Private Sub UserForm_QueryClose(Cancel As Integer, _
  CloseMode As Integer)
  If CloseMode = vbFormControlMenu Then
    Cancel = True
    MsgBox "Gebruik aub de Sluiten knop!"
  End If
End Sub
 
Upvote 0
I added the code, yet it's not showing. Should i add this code to the text field or a command button?
A command button could work. Or add it to each of the other Textbox_Change events (tklantnummer, txbVoorleters, txbTussenvoegsel, txbAchternaam). Not the topdesk_Change procedure.
 
Last edited:
Upvote 0
It's working, Magnificent! Feel free to pm me need you any adobe related help. I'm not a super expert but i know my way around those applications pretty well :)
 
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