ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Little bug in my userform (https://www.excelbanter.com/excel-programming/302083-little-bug-my-userform.html)

Stift[_34_]

Little bug in my userform
 
I've got a small 'bug' in my userform but dunno how to fix it.
Further everything is working perfectly.

When all the cells are filled and/or red background then I get th
error message: Could not set ListIndex property. Invalid propert
value.

here's the code:

Code
-------------------

Private Sub UserForm_Initialize()

Dim Cell As Range
Dim Counter As Long

Dim ListRange As Range
Dim CListRange As Range
Dim ListRangeValue() As Variant
Dim CListRangeValue() As Variant

Set CListRange = _
ActiveSheet.Range("Q9:Q106,Q113:Q162,Q169:Q183")

Set ListRange = _
ActiveSheet.Range("C9:C106,C113:C162,C169:C183")
ListRange.Style.IncludeNumber = True


ReDim ListRangeValue(0 To ListRange.Cells.Count)

For Each Cell In ListRange.Cells


If Cell.Interior.ColorIndex < 3 Then

Set Celv = Cells(Cell.Row, 16 + Weekscherm.ComboBox1.Value)

If Celv = "" Then

ListRangeValue(Counter) = Cell.Value
Counter = Counter + 1
Me.ComboBox2.AddItem (Cell.Row)
Me.ComboBox3.AddItem Cells(Cell.Row, 2)

End If
End If

Next Cell


Me.ComboBox1.List = ListRangeValue

Me.ComboBox1.ListIndex = 0 Me.ComboBox2.ListIndex = 0
Me.ComboBox3.ListIndex = 0

End Sub



Private Sub CommandButton1_Click()

X = Me.ComboBox1.ListIndex
If Me.TextBox1.Text = "" Or Me.TextBox1.Text = "" Then
X = X - 1
Else
X = Me.ComboBox1.ListIndex

Set Cel = Cells(ComboBox2.Value, 16 + Weekscherm.ComboBox1.Value)
Cel.Value = _
Me.TextBox1.Text

End If

Me.ComboBox1.ListIndex = IIf(X = 160, 0, X + 1)
Me.ComboBox2.ListIndex = Me.ComboBox1.ListIndex
Me.ComboBox3.ListIndex = Me.ComboBox1.ListIndex

Me.TextBox1.Text = ""
ComboBox1.AutoTab = True
End Sub

-------------------



I someone can help me fix this little bug I will be very please!!

Thanks in Advance,

Stif

--
Message posted from http://www.ExcelForum.com


Stift[_35_]

Little bug in my userform
 
Can noone help me ?????????? :

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Little bug in my userform
 
You can't set the listindex if there is nothing in the list

Private Sub UserForm_Initialize()

Dim Cell As Range
Dim Counter As Long

Dim ListRange As Range
Dim CListRange As Range
Dim ListRangeValue() As Variant
Dim CListRangeValue() As Variant

Set CListRange = _
ActiveSheet.Range("Q9:Q106,Q113:Q162,Q169:Q183")

Set ListRange = _
ActiveSheet.Range("C9:C106,C113:C162,C169:C183")
ListRange.Style.IncludeNumber = True


ReDim ListRangeValue(0 To ListRange.Cells.Count)

For Each Cell In ListRange.Cells


If Cell.Interior.ColorIndex < 3 Then

Set Celv = Cells(Cell.Row, 16 + Weekscherm.ComboBox1.Value)

If Celv = "" Then

ListRangeValue(Counter) = Cell.Value
Counter = Counter + 1
Me.ComboBox2.AddItem (Cell.Row)
Me.ComboBox3.AddItem Cells(Cell.Row, 2)

End If
End If

Next Cell


Me.ComboBox1.List = ListRangeValue

If combobox1.Listcount 0 then Me.ComboBox1.ListIndex = 0
If combobox2.Listcount 0 then Me.ComboBox2.ListIndex = 0
If combobox3.Listcount 0 then Me.ComboBox3.ListIndex = 0

End Sub



--
Regards,
Tom Ogilvy
"Stift " wrote in message
...
Can noone help me ?????????? :(


---
Message posted from http://www.ExcelForum.com/




Stift[_36_]

Little bug in my userform
 
Sorry Tom but that's not exaclty what I mean.

I don't no if it's possible.but the check must be in d
Commandbutton.

Something like

Code
-------------------

If Counter=0 Then
MsgBox "All data has been filled"
Unload Me
menu.show
Else

//rest of code

End Sub

-------------------


--
Message posted from http://www.ExcelForum.com


Stift[_37_]

Little bug in my userform
 
Anybody who can help me ,please do !!! I really must get this fixxed. :

--
Message posted from http://www.ExcelForum.com


Stift[_42_]

Little bug in my userform
 
Is there nobody who can help me :( :( ????????

--
Message posted from http://www.ExcelForum.com


Stift[_44_]

Little bug in my userform
 
:( :( :

--
Message posted from http://www.ExcelForum.com


Stift[_47_]

Little bug in my userform
 
I still didn't solve this problem.
The solution that was given works.But it must be fixed from th
commandbutton instead of the userform open

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 07:24 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com