Private Sub cmdSENDKEYSC_Click()
Dim X As String, y As Variant, rs As Worksheet
X = Me.ListBox1.Value 'just tells Excel the row value to copy from in Listbox1
'y = 'Textbox highlighted selection on a multitextbox userform. This highlighted selection will be copied to range B1 of row x in Sheet VSEDITS
MsgBox X 'chking to make sure coped row is correct
Sheets("VSEDITS").Range("A1").Value = X 'puts the value of x in row A1 of Sheet VSEDITS
Sheets("VSEDITS").Range("B1").Value = TextBox3.SelText 'here's where the challenge comes in. I had to identify the copied selection in the code as Textbox3. 'I want to be able to substitute the value of y for any textbox. It may be Textbox3, next time it may be Textbox4. Hence, a variable to tell Excel which textbox cursor is in.
'copy A1 and B1 values from VSEDITS to Listbox1 Rowsource sheet, which is just named NEWRESULT
Set rs = Worksheets("NEWRESULT") 'applying the typical FIND method to locate the value of LIstbox1:
With rs.Range("B:B")
Set c = .Find(What:=X, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not c Is Nothing Then
c.Offset(, 3) = Sheets("VSEDITS").Range("B1:B1").Value 'locates the correct column to paste the changed data from VSEDITS in
Else
End If
End With
'now add changes code to copy back to Sheet2. This is the main data sheet consisting of 31,103 rows of data. Final step and will be copied, pasted and saved there later.
End Sub