I am adding the columns helper to my report. Currently the VBA paste the excel formula and I want to change it to paste value instead. How do I change the excel formula to VBA language (bolded lines below)? Appreciate any tips or help or reference.
Sub Test_ACode()
Dim DateName$, ReportDate$
Dim x As Long
DateName = InputBox("Enter Report Cut Off Date MM/dd/yyyy")
ReportDate = DateName
'To add column helpers
Range("T1") = "Dist_Name"
Range("U1") = "ESC Region"
Range("V1") = "RptDate"
Range("W1") = "Age"
Range("X1") = "C_Lep"
Range("Y1") = "C_Imm"
Range("Z1") = "C_Ecodis"
Range("AA1") = "C-PK_Foster"
For Each cell In Range("A2:A" & Range("A65536").End(xlUp).Row)
'Identify cell value not equal blank
If cell.Value <> "" Then
x = 0
'Paste value when cell value does not equal blank
'but want to change below excel formulas to vba language except ReportDate
cell.Offset(x, 19).FormulaR1C1 = "=Vlookup(RC[-4],Table1,2)"
cell.Offset(x, 20).FormulaR1C1 = "=Vlookup(RC[-5],Table1,5)"
cell.Offset(x, 21).FormulaR1C1 = ReportDate
cell.Offset(x, 22).FormulaR1C1 = "=ROUNDDOWN(DATEDIF(RC[-16],RC[-1],""y""),0)"
cell.Offset(x, 23).FormulaR1C1 = "=IF(RC[-14]=1,1,"""")"
cell.Offset(x, 24).FormulaR1C1 = "=IF(Rc[-10]=1,1,"""")"
cell.Offset(x, 25).FormulaR1C1 = "=IF(OR(rc[-17]=1,rc[-17]=2,rc[-17]=99),1,"""")"
cell.Offset(x, 26).FormulaR1C1 = "=IF(OR(rc[-13]=1,rc[-13]=2),1,"""")"
x = x + 1
End If
Next
End Sub
Sub Test_ACode()
Dim DateName$, ReportDate$
Dim x As Long
DateName = InputBox("Enter Report Cut Off Date MM/dd/yyyy")
ReportDate = DateName
'To add column helpers
Range("T1") = "Dist_Name"
Range("U1") = "ESC Region"
Range("V1") = "RptDate"
Range("W1") = "Age"
Range("X1") = "C_Lep"
Range("Y1") = "C_Imm"
Range("Z1") = "C_Ecodis"
Range("AA1") = "C-PK_Foster"
For Each cell In Range("A2:A" & Range("A65536").End(xlUp).Row)
'Identify cell value not equal blank
If cell.Value <> "" Then
x = 0
'Paste value when cell value does not equal blank
'but want to change below excel formulas to vba language except ReportDate
cell.Offset(x, 19).FormulaR1C1 = "=Vlookup(RC[-4],Table1,2)"
cell.Offset(x, 20).FormulaR1C1 = "=Vlookup(RC[-5],Table1,5)"
cell.Offset(x, 21).FormulaR1C1 = ReportDate
cell.Offset(x, 22).FormulaR1C1 = "=ROUNDDOWN(DATEDIF(RC[-16],RC[-1],""y""),0)"
cell.Offset(x, 23).FormulaR1C1 = "=IF(RC[-14]=1,1,"""")"
cell.Offset(x, 24).FormulaR1C1 = "=IF(Rc[-10]=1,1,"""")"
cell.Offset(x, 25).FormulaR1C1 = "=IF(OR(rc[-17]=1,rc[-17]=2,rc[-17]=99),1,"""")"
cell.Offset(x, 26).FormulaR1C1 = "=IF(OR(rc[-13]=1,rc[-13]=2),1,"""")"
x = x + 1
End If
Next
End Sub