VBA to Extract Amount from a Database

MikeeRDX

Board Regular
Joined
Feb 16, 2014
Messages
98
Hi,

I have created the VBA code to extract numerical data from a database; however, I'm having a lot of difficulty in doing the same for data that is in currency format. Below is a sample of my database. Can you help with a proper VBA code to get this to work? Thank you all.
Item Number
Incoming/ OutgoingDate of EntryIssued DateDue DateCheck Amount
6150111Incoming Collection9/9/2014
8/20/201411/1/2014$555.55
6151001Outgoing Collection5/20/20144/14/20147/1/2014$2,741.94
6151214Outgoing Collection6/19/20141/2/20147/31/2014$300.00

<tbody>
</tbody>



I'm able to retrieve the record by Item Number fine. However, if I input the Amount in my textbox designated for amount and click on Find button, it doesn't locate the item. Below is the VBA code I created:

Private Sub CmdFamt_Click()
Dim lastrow
Dim amount As Integer
lastrow = Sheets("sheet1").Range("y" & Rows.Count).End(xlUp).Row
amount = txtIamt.Value
For currentrow = 14 To lastrow
If Cells(currentrow, 25).Text = amount Then

txtIamt.Text = Cells(currentrow, 25).Value
txtItem.Text = Cells(currentrow, 17)
txtInst.Text = Cells(currentrow, 18)
txtPayor.Text = Cells(currentrow, 19)
txtPayee.Text = Cells(currentrow, 20)
txtType.Text = Cells(currentrow, 21)

txtIamt.Text = Format(txtIamt.Text, "$#,##0.00")
txtFee.Text = Format(txtFee.Text, "$#,##0.00")
txtFcharge.Text = Format(txtFcharge.Text, "$#,##0.00")
txtAmtpd.Text = Format(txtAmtpd.Text, "$#,##0.00")

End If
Next currentrow
txtItem.SetFocus
End Sub



<colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:2962;width:61pt" width="81"> <col style="mso-width-source:userset;mso-width-alt:2596; width:53pt" span="4" width="71"> </colgroup><tbody>
</tbody>














<colgroup><col style="width:48pt" width="64"> <col style="mso-width-source:userset;mso-width-alt:2962;width:61pt" width="81"> <col style="mso-width-source:userset;mso-width-alt:2596; width:53pt" span="4" width="71"> </colgroup><tbody>
</tbody>
 

Some videos you may like

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Watch MrExcel Video

Forum statistics

Threads
1,109,028
Messages
5,526,332
Members
409,696
Latest member
EERS

This Week's Hot Topics

Top