Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
zz zz is offline
external usenet poster
 
Posts: 32
Default this code makes excel crash

i have this code in a userform called view_employees

now in my code i want to display a list that i keep in a sheet named
"empleados"

if range "a2" is empty i want to hide the listview i use to display the
list and display a simple label with a message about no employees to show

if i have values in the cell it runs ok, with the help of some folks in the
spanish newsgroups it even runs faster, but when there are no values in the
cell ["a2"], it makes excel to crash.

i look at the code and know there are better ways to do this, but it was
working before, i just changed the validation of the value of cell a2 and
instead of doing it in the load_list sub y changed it to not even run the
load_list sub if the cell value is blank, but it still crashes.

and sincerely dont know where the hook may be!!!


i really really need help...



---- here's my code ---

Private Sub Lbladd_new_Click()
' this is label is used to call a userform used to add a
new employee
add_employee.Show
End Sub

Private Sub load_list()
' this loads the list of employees in a listview
On Error GoTo errhandler
Me.listempleados.ListItems.Clear ' so we do not get duplicated
entries
With Sheets("empleados")
Dim indx As Integer
indx = 1
Do Until Range("A" & indx).Value = ""
Me.listempleados.ListItems.Add indx, , .Range("A" &
indx).Offset(1, 1).Value 'numero de empleado
Me.listempleados.ListItems(indx).ListSubItems.Add , ,
Range("A" & indx).Offset(1, 2).Value 'nombre
Me.listempleados.ListItems(indx).ListSubItems.Add , ,
Range("A" & indx).Offset(1, 3).Value 'ap paterno
Me.listempleados.ListItems(indx).ListSubItems.Add , ,
Range("A" & indx).Offset(1, 4).Value 'ap materno
Me.listempleados.ListItems(indx).ListSubItems.Add , ,
Range("A" & indx).Offset(1, 5).Value 'entrenador
indx = indx + 1
Loop
End With
errhandler:
Exit Sub
End Sub

Private Sub LblRefresh_Click()
' once a employee is added this label refreshes the listview
contents
load_list
End Sub

Private Sub UserForm_Initialize()
' here is where i changed the validation
If Sheets("empleados").Range("a2").Value = "" Then
Me.listempleados.Visible = False
Else
load_list
End If
End Sub


i suspect the if clausule in the userform initialize part is not doing it's
job, and it tries to load the entire column values but i'm just guessing.



BTW: sorry by all spanglish in the code, but there are some variable name i
remember the best in english and other i do remember better in spanish.



--
---
zz [MX]
cuasi-musico,semi-poeta y loco


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
XLA makes XL2003 crash Soren[_2_] Excel Programming 3 September 27th 05 01:40 PM
XLA makes XL2003 crash Soren[_2_] Excel Programming 0 September 26th 05 09:31 AM
stubborn Excel crash when editing code with code, one solution Brian Murphy Excel Programming 0 February 20th 05 05:56 AM
checkbox code makes excel sloowwwww... Scott Excel Programming 4 September 9th 04 05:55 PM
Excel crash error code Ed[_17_] Excel Programming 1 February 16th 04 10:46 AM


All times are GMT +1. The time now is 10:57 PM.

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"