View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
oli merge oli merge is offline
external usenet poster
 
Posts: 50
Default Application.enableevents = false not working in workbook open

And the listbox change code is:


Private Sub ListBox1_change()

Dim HWks As Worksheet
Dim cCtr As Long
Dim myRng As Range

Set HWks = Worksheets("Hidden")

With HWks
Set myRng = .Range("A1", .Cells(.Rows.Count, "A").End(xlUp))
End With

With ActiveSheet.ListBox1
For cCtr = 0 To .ListCount - 1
myRng.Cells(1).Offset(cCtr, 1).Value = .Selected(cCtr)
Next cCtr


End With
With HWks
Set myRng = .Range("C1", .Cells(.Rows.Count, "C").End(xlUp))
End With

With ActiveSheet.ListBox2
For cCtr = 0 To .ListCount - 1
myRng.Cells(1).Offset(cCtr, 1).Value = .Selected(cCtr)
Next cCtr
End With

With HWks
Set myRng = .Range("E1", .Cells(.Rows.Count, "E").End(xlUp))
End With

With ActiveSheet.ListBox3
For cCtr = 0 To .ListCount - 1
myRng.Cells(1).Offset(cCtr, 1).Value = .Selected(cCtr)
Next cCtr
End With


With HWks
Set myRng = .Range("G1", .Cells(.Rows.Count, "G").End(xlUp))
End With

With ActiveSheet.ListBox4
For cCtr = 0 To .ListCount - 1
myRng.Cells(1).Offset(cCtr, 1).Value = .Selected(cCtr)
Next cCtr
End With


End Sub


There are 4 version of this for 4 listboxes, each listbox change saves all 4
of the listboxes as you can see, which is probably totally unneccesary but I
just did it so I could copy and paste it quicker (and the run time of the
macro is not noticeable anyway).

Thanks!