The question is – can this be done generically with a few lines of code (few =?)? - that is, Excel has to know which textbox of which userform in an application with say, 10 Userforms containing several textboxes on each userform? It's like saying the active textbox of the active userform
I tried to be as short but as complete as possible in this description. Here it is:
Each textbox gets its text and displays it from a Listbox Rowsource property of each userform of a specific sheet the results of a FIND method copies to.
With the code I have below, I can highlight, select, copy and paste any text selected to any specific sheet but it only correctly performs the operation for one specific textbox on one specific userform at a time.
This is a lot of code to have to continually copy to different buttons on different userforms.
As it stands now, If I want to be able to do this on any and all textboxes on any and all userforms – I’d have to copy this entire code block below to all userform buttons. and make changes to code lines where indicated above. A painstaking process.
The way I see it is that the only way to do this is that the code must be generic – that is Excel must be able to “recognize” each userform and textbox independently, and the text that is being highlighted and selected - the same as the Activetextbox on the Activeuserform(if there are such things) and run the rest of the code.
Hopefully, there's a way to highlight and select any text in multiuserform multitextbox an application do this without recopying so much code.
I would really appreciate anyone's help in this
cr
I tried to be as short but as complete as possible in this description. Here it is:
Each textbox gets its text and displays it from a Listbox Rowsource property of each userform of a specific sheet the results of a FIND method copies to.
With the code I have below, I can highlight, select, copy and paste any text selected to any specific sheet but it only correctly performs the operation for one specific textbox on one specific userform at a time.
Code:
Private Sub cmdEDITVERSE_Click()
Sheets("VSEDITS").Range("A1:B1").ClearContents
Dim s As String, vs As Worksheet
s = Me.TextBox8.Value 'CHG SHT NAME. USE s VAR – >>>THIS CHANGES WITH EACH USERFORM
With BIBLETEXTWINDOW.NASB - – >>> REFERENCES SHEET NAME OF USERFORM NAME. THIS CHANGES W EACH USERFORM
.SelStart = 0
.SelLength = Len(.Text)
.Copy
End With
cmdEDITVERSE.SetFocus
Set vs = Sheets("VSEDITS")---> just copies to a temporary "holding") sheet
vs.Cells(1, 1).Value = s '
vs.paste Destination:=vs.Range("B1")
Sheets("VSEDITS").Range("A2:B100").ClearContents
Dim X As String, c As Range, ws, rs As Worksheet
Set ws = Worksheets("Sheet2") - MAIN DATA SHEET WHERE CHANGES ARE STORED AND SAVED
With ws.Range("B:B")
Set c = .Find(What:=TextBox8.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) 'CHG FIND WHAT VALUE
X = c.Offset(, 3).Value 'offset number from col B i1=KJV, 2=NIV, 3=NASB, 4=RSV - each col is a version down to 31103 rows
If Not c Is Nothing Then
c.Offset(, 3) = Sheets("VSEDITS").Range("B1:B1")
Else
'MsgBox "Can't find " & TextBox8.Value 'CHG TEXTBOX NAME
End If
End With
Set rs = Worksheets("RESULT") 'THIS CHANGES TO A DIFFERENT SHEET FOR EACH LISTBOX DATA COPIED FIND RESULTS TO
With rs.Range("B:B") - THIS COL CHANGES
Set c = .Find(What:=TextBox8.Value, LookIn:=xlValues, LookAt:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False) 'CHG FIND WHAT VALUE
If Not c Is Nothing Then
c.Offset(, 3) = Sheets("VSEDITS").Range("B1:B1").Value '+ " " & D
Else
End If
End With
BIBLETEXTWINDOW.TextBox1.SelStart = 0 'BIBLETEXTWINDOW = Userform name. THIS CHANGES TO USERFORM NAME AND SHT NAME
End Sub
As it stands now, If I want to be able to do this on any and all textboxes on any and all userforms – I’d have to copy this entire code block below to all userform buttons. and make changes to code lines where indicated above. A painstaking process.
The way I see it is that the only way to do this is that the code must be generic – that is Excel must be able to “recognize” each userform and textbox independently, and the text that is being highlighted and selected - the same as the Activetextbox on the Activeuserform(if there are such things) and run the rest of the code.
Hopefully, there's a way to highlight and select any text in multiuserform multitextbox an application do this without recopying so much code.
I would really appreciate anyone's help in this
cr
Last edited: