Hello All,
I am new to these forums, and relatively new to VBA in Excel. I have created a userform to input a bit of data. One of the things I needed to do was create a ListBox of over 350 items that was searchable. I accomplished this, but in order for my data to be input into the worksheet correctly, I had to create an Add to List button, and move the selected option to a text box. I also created a remove all button to empty the box. Currently, I am trying to create a delete last entry button so that the very last entry is deleted. All entries are followed by the string “; “, so I could use this as the marker before the last item, but I cannot provide a character count, as each item varies in length (this is a hazmat form, and has CAS no, and varying length chemical names).
I have tried creating a function:
Private Function LastString() as integer
str = SelectedEHSList.Value
LastString = InStrRev(str, “;”, 2, vbTextCompare)
End Function
Then I would call it in the sub for the RemoveLast_Click()
Problem is, I do not know how to turn the LastString value into the amount of characters -1 that I want to remove.
Any help is greatly appreciated, this is work-related project. The remove last button isn’t necessary, as I have the remove all button, but it would be a nice convenience for the end-user (especially as this form will be used a few hundred to thousand times each year).
Thank You!
PS: my home computer, which is what I will be using for most of my chatting on here is an iPad Pro, which Apple has yet to outfit with coding capabilities (sadly), and my work computer is a secured device where I am not supposed to download. So please post any suggestions as code within for me to reference. Thanks! (Also means I can’t attach)