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>
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

Forum statistics

Threads
1,214,833
Messages
6,121,868
Members
449,053
Latest member
Mesh

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top