PDA

View Full Version : [SOLVED:] ComboBox not refreshing



Olwa
06-21-2017, 05:17 AM
Hey guys,
general question: does anyone of you know why, in some cases, a combobox does not refresh but show as empty? Usually i just clear the boxes and re-initialize the userform after any changes and it works fine. Right now i can't seem to figure out a way to fix it though.
Fun fact: If i click on another combobox beforehand (that also shows as empty, but intended, as it fills depending on the first comboboxs entry) it works afterwards.

Regards

snb
06-21-2017, 05:23 AM
The only explanation that comes to mind: clumsy coding.
You can invalidate that explanation by showing your file.

PS. Are you familiar with CEF-DE (http://www.clever-excel-forum.de/forum-2.html)

Olwa
06-21-2017, 11:46 PM
As i've barely got any experience in vba i am pretty sure my code is clumsy. ;)
As im clicking label3 on userform5 i want it to disappear, search sheet1/column1 for the value set in combobox1 and delete all rows that contain said value. After that i want to search for the same value in sheet2/column1 and delete the row that contains the value. Clear the boxes and initialize the userform.



Private Sub label3_click()

UserForm5.Hide

lIndex = Sheets(1).Cells(Rows.Count, 2).End(xlUp).Row
Do While lIndex > 0
If Sheets(1).Cells(lIndex, 1).Value = UserForm1.ComboBox1.Value Then
Sheets(1).Rows(lIndex).EntireRow.Delete
End If
lIndex = lIndex - 1
Loop

chIndex = 2
Do Until Sheets(2).Cells(chIndex, 1).Value = UserForm1.ComboBox1.Value
chIndex = chIndex + 1
Loop
Sheets(2).Rows(chIndex).EntireRow.Delete

UserForm1.ComboBox1.Clear
UserForm1.ComboBox2.Clear
UserForm1.ListBox1.Clear
UserForm1.UserForm_Initialize

End Sub

Guess the "error" is not due to this part of the code?

snb
06-21-2017, 11:58 PM
No file, no idea (keine Datei, keine Ahnung).

Olwa
06-22-2017, 05:39 AM
I coded an example to show what i mean without uploading the file (cause im rlly not allowed to do so). Too bad the file actually works, so there seems to be something wrong within my endless code, haha. Guess this is solved then.