I have a user form with a listbox at the bottom of the form, I want to able
to select a record to edit or ad new record but when I select the a customer the form fields doesn't shows the record on form to edit.
here it's the code on listbox:
please help.
thanks
to select a record to edit or ad new record but when I select the a customer the form fields doesn't shows the record on form to edit.
here it's the code on listbox:
Code:
Private Sub ARLIST1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim Name As String
Dim firstaddress As String
'Private Sub ARLIST1_Click()
TextBox1 = ARLIST1
For Each bul In Range("B1:B" & WorksheetFunction.CountA([b1:b65536]))
If StrConv(bul, vbUpperCase) = StrConv(TextBox1, vbUpperCase) Then
bul.Select
TextBox1 = ActiveCell.Offset(0, 0)
TextBox2 = ActiveCell.Offset(0, 1)
TextBox3 = ActiveCell.Offset(0, 2)
TextBox4 = ActiveCell.Offset(0, 3)
TextBox5 = ActiveCell.Offset(0, 4)
TextBox6 = ActiveCell.Offset(0, 5)
TextBox7 = ActiveCell.Offset(0, 6)
TextBox8 = ActiveCell.Offset(0, 7)
TextBox22 = ARLIST1.ListIndex - 1
End If
Next
Customer = Empty
'If you add more than 500 names you will need to increase this
With ActiveSheet.Range("a2:e1000")
Name = ARLIST1.Value
Set Customer = .Find(What:=Name, LookIn:=xlValues)
If Not Customer Is Nothing Then Customer.Rows.EntireRow.Select Else Exit Sub
End With
'closes the form when you click on a name
' Unload Me
Dim ce As Range, i As Long
Dim OutApp As Object
Dim OutMail As Object
Dim strto As String, strcc As String, strbcc As String
Dim strsub As String, StrBody As String
Dim wksht As Worksheet
Dim rw As Integer
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Set wksht = Worksheets("ContactsInvoicing")
rw = ActiveCell.Row
strto = wksht.Cells(rw, "C").Value
strcc = "ar@hyperwallet.com" & ";" & wksht.Cells(rw, "K").Value & ";" & wksht.Cells(rw, "M").Value
strbcc = ""
strsub = wksht.Cells(rw, "N").Value
StrBody = "Hello" & " " & wksht.Cells(rw, "B").Value & ", " & vbCrLf & vbCrLf & "" & wksht.Cells(rw, "O").Value
'End With
With OutMail
.To = strto
.CC = strcc
.BCC = strbcc
.Subject = strsub
.Body = StrBody
.display
End With
Set OutMail = Nothing
Set OutApp = Nothing
Set Customer = Nothing
With UserForm2
Unload Me
End With
End Sub
please help.
thanks