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.
<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>
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/ Outgoing | Date of Entry | Issued Date | Due Date | Check Amount |
6150111 | Incoming Collection | 9/9/2014 | 8/20/2014 | 11/1/2014 | $555.55 |
6151001 | Outgoing Collection | 5/20/2014 | 4/14/2014 | 7/1/2014 | $2,741.94 |
6151214 | Outgoing Collection | 6/19/2014 | 1/2/2014 | 7/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>