This question already has an answer here:
Good Afternoon,
I'm fairly new to VBA, and have a beginner question regarding applying "IF" Formulas to a set of cell values that contain special characters.
Problem: I use a risk model that spits out market instrument values of the underlying positions. When these values are $0.00 they come up as just $ in the cell. The goal here is anytime there is a $ in a cell, I'd like them to be replaced with $0.00.
I don't want these formulas applied to the cells beforehand, because these values are copied and pasted daily, therefore - I would run this step after the data pulls.
The IF Function I want to use looks like this: =IF(D316="$","$0.00",D316) So if D316 = the $, it will return $0.00, instead of $. If it doesn't show up as just $, then put the actual value, which could be like $1,000.
When I try to model this out in VBA, the special character $ gives me some issues.
Dim FileName As String
Dim FilePath As String
Dim PreviousWorkday As String
Dim DateValue As String
Dim MainBook As Workbook
Dim Template As Worksheet
DateValue = InputBox("Enter Previous Business Date in this format MM-DD-YYYY", "Date", "Example MM-DD-YYYY")
FileName = DateValue & " Performance Report.xlsm"
FilePath = "\PERFORMANCE REPORTS\"
ThisWorkbook.Activate
Sheets("testing").Select
Range("D315").Select
Selection.End(xlDown).Select
Sheets("testing).Range("D315").Formula = _
"=IF(D315="$","$0.00",D315)"
I get a compile error that highlights the $ sign.
Aucun commentaire:
Enregistrer un commentaire