View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default What is missing from this form code?

where do you declare your VisitDate variable or is that the name of your
listbox?
If that is the name of the listbox then what is VisitList? I think your
problem lies between these two. One is apparently a name and the other a
variable. The variable has not been declared.

"Leanne" wrote:

Can anyone help identify why this is not working correctly. Following is the
full code from the form. Myself and another member have worked on this but
can not resolve the problem.

This code is used for a 2 page form that takes information from the sheet to
create the combo Boxes (.....List).

What it is not doing, is entering the data from the text box (.....Date)
back into the sheet (Called Dates - Invoice goes in col B and Visit Col C) -
against the entry that has been selected from the combo box (range of
customer names from col A).

----------------------------------
Option Explicit

'This searches for the seletion in the comboBox
'Then goes to the Column to input the date entered

Sub SaveVisit_Click()

Dim foundCell As Range

With Worksheets(1).Range("A1:A65536")

Set foundCell = .Find(What:=VisitList.Value, lookAt:=xlWhole, _
LookIn:=xlValues, SearchOrder:=xlRows, _
MatchCase:=True, MatchByte:=True)

If Not foundCell Is Nothing Then
foundCell.Offset(0, 2).Value = VisitDate.Value
End If
End With
VisitList.Value = ""
VisitDate.Value = ""
End Sub
'This way your company list stays in its
'current range & only the dates change
-------------------------------------------------
Private Sub SaveInvoice_Click()

Dim foundCell As Range

With Worksheets(1).Range("a1:a65536")

Set foundCell = .Find(What:=InvoiceList.Value, lookAt:=xlWhole, _
LookIn:=xlValues, SearchOrder:=xlRows, _
MatchCase:=True, MatchByte:=True)

If Not foundCell Is Nothing Then
foundCell.Offset(0, 1).Value = InvoiceDate.Value
End If
End With
InvoiceList.Value = ""
InvoiceDate.Value = ""
End Sub
--------------------------------------------------
Private Sub CloseVisit_Click()
Unload Me
End Sub
---------------------------------------------------
Private Sub CloseInvoice_Click()
Unload Me
End Sub
---------------------------------------------------
'This will use your Sheets
'Data to populate the ComboBox
'Your ComboBox will then be able to grow as your list grows

Private Sub UserForm_Initialize()
VisitList.RowSource = "Dates!A2:A300"
InvoiceList.RowSource = "Dates!A2:A300"
End Sub