Hi Folks,
I am getting stuck in what i believe could be a simple code.
I have a textbox with values for Contracts separated by a ";" (Ex: 205111; 450325; 12000Rev-1) or (Ex: 14522Rev2; 125001) or (Ex: 195654).
What i would like to do is when i press a button, each Contract that is in between the ";" goes to a different Variable. I started with this code
Public Sub ContractIDPopup()
Dim FinalContractID, Contract1, Contract2, Contract3 As String
Dim countSeparators As Variant
FinalContractID = ActiveSheet.TextBoxes("7Contract ID").text
countSeparators = UBound(Split(FinalContractID, ";"))
Contract1 = Split(FinalContractID, ";")(0)
Contract2 = Split(FinalContractID, ";")(1)
End Sub
This works if i have only one ";". The problem is when i have 3 Contracts. In that case i would need:
- Left of the first ";"
- In between the two ";"
- Right of the second ";"
Is this possible?
EDIT: The contracts Lenght is variable
Cheers
I am getting stuck in what i believe could be a simple code.
I have a textbox with values for Contracts separated by a ";" (Ex: 205111; 450325; 12000Rev-1) or (Ex: 14522Rev2; 125001) or (Ex: 195654).
What i would like to do is when i press a button, each Contract that is in between the ";" goes to a different Variable. I started with this code
Public Sub ContractIDPopup()
Dim FinalContractID, Contract1, Contract2, Contract3 As String
Dim countSeparators As Variant
FinalContractID = ActiveSheet.TextBoxes("7Contract ID").text
countSeparators = UBound(Split(FinalContractID, ";"))
Contract1 = Split(FinalContractID, ";")(0)
Contract2 = Split(FinalContractID, ";")(1)
End Sub
This works if i have only one ";". The problem is when i have 3 Contracts. In that case i would need:
- Left of the first ";"
- In between the two ";"
- Right of the second ";"
Is this possible?
EDIT: The contracts Lenght is variable
Cheers
Last edited: