View Single Post
  #8   Report Post  
Dave Peterson
 
Posts: n/a
Default

I put this in a general module:

Option Explicit
Public weapon As Long

Sub dialog1_unload()

Dim myPopup As DialogSheet
Dim myString As String

Set myPopup = ThisWorkbook.DialogSheets("Popup")

If myPopup.ListBoxes("listbox5").Value < 1 Then
MsgBox "None selected!"
Exit Sub
End If

With myPopup.ListBoxes("listbox5")
myString = .List(.ListIndex)
End With

With Worksheets("Weapons and Armor")
Select Case weapon
Case 1
.Range("$D$18").Value = myString
Case 2
.Range("$G$18").Value = myString
Case 3
.Range("$J$18").Value = myString
Case 4
.Range("$M$18").Value = myString
Case 5
.Range("$P$18").Value = myString
End Select
End With

End Sub

(And kept your code under the sheet with the checkboxes.)

The listbox from the Forms toolbar (like the one you used on the Dialog sheet
doesn't return the value of the selected item. It returns an index into that
list. So myString looks at that item in the list.



Brad Sumner wrote:

This is the code for the 5 check boxes that can bring up the popup

Private Sub chkW1TwoWeap_Click()
Weapon = 1
If Me.chkW1TwoWeap.Value = True Then
ThisWorkbook.DialogSheets("popup").Show
End If
End Sub

Private Sub chkW2TwoWeap_Click()
Weapon = 2
If Me.chkW2TwoWeap.Value = True Then
ThisWorkbook.DialogSheets("popup").Show
End If
End Sub

Private Sub chkW3TwoWeap_Click()
Weapon = 3
If Me.chkW3TwoWeap.Value = True Then
ThisWorkbook.DialogSheets("popup").Show
End If
End Sub

Private Sub chkW4TwoWeap_Click()
Weapon = 4
If Me.chkW4TwoWeap.Value = True Then
ThisWorkbook.DialogSheets("popup").Show
End If
End Sub

Private Sub chkW5TwoWeap_Click()
Weapon = 5
If Me.chkW5TwoWeap.Value = True Then
ThisWorkbook.DialogSheets("popup").Show
End If
End Sub

This is the code I tried in the popup coding to return the value of what was
chosen

Sub dialog1_unload()
Select Case Weapon
Case 1
Range("'Weapons and Armor'!$D$18").Select
ActiveCell.Value = popup.Listbox5.Value
Case 2
Range("'Weapons and Armor'!$G$18").Select
ActiveCell.Value = popup.Listbox5.Value
Case 3
Range("'Weapons and Armor'!$J$18").Select
ActiveCell.Value = popup.Listbox5.Value
Case 4
Range("'Weapons and Armor'!$M$18").Select
ActiveCell.Value = popup.Listbox5.Value
Case 5
Range("'Weapons and Armor'!$P$18").Select
ActiveCell.Value = popup.Listbox5.Value
End Select
End Sub


--

Dave Peterson