Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50094

listbox code needs adapting

$
0
0
hi all

how can i adapt this bit of code so when i select an item in the listbox then that item gets pasted to a cell. here is my full code

Code:

Private Sub NOutSave_Click()
Dim Nextrow As Integer

'This makes sure all fields are completed before info is submited
If UserForm1.DateAdd.Value = "" _
    Or UserForm1.DateAdd.Value = "" Then
        MsgBox "Please Fill In ALL Box's", vbOKOnly + vbInformation, ""
       
        Else


'=COUNTA(A:A)+1
Nextrow = WorksheetFunction.CountA(Sheets("Night Out").Range("A:A")) + 1


UserForm1.DateAdd.Value = Sheets("Night Out").Cells(Nextrow, 1)
UserForm1.LocListAdd.Value = Sheets("Night Out").Cells(Nextrow, 2)
UserForm1.TypeAdd.Value = Sheets("Night Out").Cells(Nextrow, 3)
UserForm1.CostAdd.Value = Sheets("Night Out").Cells(Nextrow, 4)
UserForm1.SafeAdd.Value = Sheets("Night Out").Cells(Nextrow, 5)
UserForm1.NotesAdd.Value = Sheets("Night Out").Cells(Nextrow, 6)



Me.DateAdd.Value = ""
Me.TypeAdd.Value = ""
Me.CostAdd.Value = ""
Me.SafeAdd.Value = ""
Me.NotesAdd.Value = ""

End If
End Sub

and this is the bit that is not copying infact none if my textboxes are copying for some reason but i think its down to this bit of code

Code:

UserForm1.LocListAdd.Value = Sheets("Night Out").Cells(Nextrow, 2)
what im doing is adding a date to my date box and then selecting an item from my listbox which inturn fill in the required data into other boxes. so once ive add the date it should have to my night out page but its not.

Viewing all articles
Browse latest Browse all 50094

Trending Articles