Hello,
I have the code below to get the lookup amount of the selected client from sheet5, but I don't know what I did wrong since it's not showing the amount on the "txtTotal, can you please help me to get the amount of the selected client?
Note: the Amounts on column "D" contains formulas
[TABLE="class: grid, width: 800"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]ID[/TD]
[TD]Name[/TD]
[TD]Phone[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]100[/TD]
[TD]Cash Client[/TD]
[TD][/TD]
[TD]2000[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]101[/TD]
[TD]Nadim[/TD]
[TD][/TD]
[TD]3000[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]102[/TD]
[TD]Rami[/TD]
[TD][/TD]
[TD]4000[/TD]
[/TR]
</tbody>[/TABLE]
I have the code below to get the lookup amount of the selected client from sheet5, but I don't know what I did wrong since it's not showing the amount on the "txtTotal, can you please help me to get the amount of the selected client?
Note: the Amounts on column "D" contains formulas
Code:
Private Sub cmdContact_Click()
On Error Resume Next
If WorksheetFunction.CountIf(Sheet5.Range("B:B"), Me.cboName.Text) = 0 Then
MsgBox "This client is not exist"
Me.cboName.Value = "Cash Client"
Exit Sub
End If
With Me
.txtTotal.Value = Application.WorksheetFunction.VLookup(Me.cboName.Text, Sheet5.Range("A1").CurrentRegion, 4, 0)
End With
End Sub
[TABLE="class: grid, width: 800"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]ID[/TD]
[TD]Name[/TD]
[TD]Phone[/TD]
[TD]Amount[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]100[/TD]
[TD]Cash Client[/TD]
[TD][/TD]
[TD]2000[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]101[/TD]
[TD]Nadim[/TD]
[TD][/TD]
[TD]3000[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]102[/TD]
[TD]Rami[/TD]
[TD][/TD]
[TD]4000[/TD]
[/TR]
</tbody>[/TABLE]