can anyone help in below VBA code , it takes data from column A & B & adds it,
problem is I need to press F2 to refresh formula:
example - A = 6(1+2+3)
and B = 15(4+5+6)
,
Code result = +=1+2+3+=4+5+6
I have to Manually press F2 & accept formula to calculate result, what I can add to code so it calculates automatically, below is my VBA code?
Is there any way I can get formula accepted by cell, my data may have "+" or "=" symbol in between data for example: =+1+2+3=+4+5+6
.
Sub datashftfinal1()
Dim i As Integer
Dim val1 As String
Dim val2 As String
Dim valF As String
For i = 1 To 10
If Cells(i + 1, 2).Value >= 0 Then
val1 = Cells(i + 1, 1).FormulaR1C1
val2 = Cells(i + 1, 2).FormulaR1C1
valF = "+" & val1 & "+" & val2
Cells(i + 1, 1).FormulaR1C1 = valF
End If
Next i
End Sub
Sample Data
Column A1
=1+2+3
Column B1
=4+5+6
i have given formula view of data in above data sample, i am getting result as below after running code:
=1+2+3+=4+5+6
Its not calculating result instead showing formula, i need to press F2 and accept Formula, below is my Code:
enter code here
Sub Data()
Dim i As Integer
Dim val1 As String
Dim val2 As String
Dim valF As String
For i = 1 To 10
If Cells(i + 1, 2).Value >= 0 Then
val1 = Cells(i + 1, 1).FormulaR1C1
val2 = Cells(i + 1, 2).FormulaR1C1
valF = "+" & val1 & "+" & val2
Cells(i + 1, 1).FormulaR1C1 = valF
End If
Next i
End Sub