Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code crashes when ComboB = empty

Hi everyone, I've got a userform where users can enter data into a
excelsheet.

ComboBox1 will be filled with descriptions from a range cells.
When the backgroundcolor of a cell red is, it will be skipped and als
when de data already is filled in.
But when all data is filled and/or backgrounds are redcolored I get a
ListIndex error.

Please help me fix this, I really need it.



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

Private Sub UserForm_Initialize()

Dim Cell As Range
Dim Counter As Long
Dim ListRange As Range
Dim ListRangeValue() As Variant

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)
'MsgBox Cells(Cell.Row, 2)
End If
End If
Next Cell

TextBox1.SetFocus
Me.ComboBox1.List = ListRangeValue
Me.ComboBox1.ListIndex = 0
Me.ComboBox3.ListIndex = 0
TextBox6.Value = Weekscherm.ComboBox1.Value
End If

End Sub

Private Sub CommandButton1_Click()
X = Me.ComboBox1.ListIndex
If Me.TextBox1.Text = "" Or Me.TextBox1.Text = "" Then
MsgBox "TextBox = empty"
X = X - 1
Else
Set Cel = Cells(ComboBox2.Value, 16 + Weekscherm.ComboBox1.Value)
Cel.Value = _
Me.TextBox1.Text
Me.ComboBox1.ListIndex = IIf(X = 160, 0, X + 1)
Me.ComboBox2.ListIndex = Me.ComboBox1.ListIndex
Me.ComboBox3.ListIndex = Me.ComboBox1.ListIndex
Me.TextBox1.Text = ""
End If

End Su
-------------------


I'm a very bad programmer and created this code with examples,
so please help meeeeeeeeeee !!!!
10000000000000x THANKS in Advanc

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code crashes when ComboB = empty

:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code crashes after clearing comments L. Howard Kittle Excel Worksheet Functions 2 February 20th 06 04:54 AM
How do I reference data from one worksheet to another using combob caricc New Users to Excel 0 December 17th 05 09:58 PM
How to empty the clipboard using vba code Robin Ketting Excel Programming 1 February 17th 04 11:35 AM
Help... This code consistently crashes for no reason. Yo Excel Programming 3 February 5th 04 09:13 AM
Code in ThisWorkbook crashes Excel Pat Beck Excel Programming 6 August 25th 03 09:07 AM


All times are GMT +1. The time now is 10:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"