LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Error populating a list box

Got the error!

Another sub was had an unload instruction and it is causing the error.

Any suggestion on how I can fix this? The idea was when "OK" is pressed this form unload and another one to input password is open. if you user press cancel in the second one the first is open again and so on...

to pass value between forms I use a trick of putting the selection value in a spreadsheet (ActiveWorkbook.Sheets("Menu").Cells(2, 9).Value = Selection) not the most elegant option but kind of works. I would appreciate more efficient solutions...

Thanks a million,
PA



Private Sub CommandButton3_Click()
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
End Sub

Private Sub listbox1_Click()
Dim Selection As String
Selection = ListBox1.List(ListBox1.ListIndex, 0)
ActiveWorkbook.Sheets("Menu").Cells(2, 9).Value = Selection
Unload Me
End Sub

Private Sub UserForm_Initialize()
Dim lbtarget As MSForms.ListBox
Dim ws As Worksheet
Dim rngSource As Range
Dim count As Integer
Set ws = ActiveWorkbook.Sheets("Utilizadores")
count = Application.count(Range(ws.Cells(2, 1), ws.Cells(200, 1)))
Set rngSource = Range(ws.Cells(2, 1), ws.Cells(count + 1, 2))
Set lbtarget = Me.ListBox1
With Me.ListBox1
.Clear
.ColumnCount = 2
.ColumnWidths = "20;280"
.List = rngSource.Cells.Value
'.ListIndex = 3
End With
End Sub


Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = vbFormControlMenu Then
Cancel = True
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
End If
End Sub


 
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
Error populating a list box PA[_2_] Excel Programming 1 July 5th 11 03:06 PM
Error populating a list box PA[_2_] Excel Programming 1 July 5th 11 12:59 PM
.AddItem list and populating combobox with created list pallaver Excel Discussion (Misc queries) 8 June 27th 08 12:36 PM
Populating a List Box Eric Excel Programming 1 October 1st 07 04:23 PM
Populating dropdown list 2 with data depending upon what was selected in list 1 karambos Excel Programming 2 November 9th 04 05:32 PM


All times are GMT +1. The time now is 01:42 AM.

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

About Us

"It's about Microsoft Excel"