ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help please - real beginner at form code (https://www.excelbanter.com/excel-programming/409659-help-please-real-beginner-form-code.html)

Leanne

Help please - real beginner at form code
 
Hi, I have the following code in a form but do not know how to do the
following with it.
1. The CmbSiteList is a combo box and I do not know how to generate the
options as there are many and chaning. This would contain a list of company
names that is ever growing. These company names are on the sheet 'Dates' but
are determined by another sheet which is the master list. Entries in the
'Dates' sheet calculate new data for the master list also.

2. When I copy the data to the database I want only the entry in CmbSiteList
updated with what is in the text box TxtDate.

Please can someone help as the code I have so far I have taken from
http://www.contextures.on.ca/xlUserForm01.html#SetUp and have not written
myself as I would not know how.

Private Sub SaveVisit_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Dates")

'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row

'check for a part number
If Trim(Me.TxtDate.Value) = "" Then
Me.TxtDate.SetFocus
MsgBox "Please enter a valid Date"
Exit Sub
End If
If Trim(Me.CmbSiteList.Value) = "" Then
Me.CmbSiteList.SetFocus
MsgBox "Please select a Site"
Exit Sub
End If

'copy the data to the database
ws.Cells(iRow, 1).Value = Me.CmbSiteList.Value
ws.Cells(iRow, 2).Value = Me.TxtDate.Value

'clear the data
Me.CmbSiteList.Value = ""
Me.TxtDate.Value = ""
Me.CmbSiteList.SetFocus

End Sub
Private Sub CloseVisit_Click()
Unload Me
End Sub


All times are GMT +1. The time now is 02:40 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com