mardi 14 octobre 2014

creating a formula string in VBA using part formula and part hard coded string


Vote count:

0




Dim cell_range As range Set cell_range = Worksheets("beans").range("T11")


Dim x As Integer x = 0 Dim current_range As range Set current_range = cell_range


Do Dim actual_test_range As String actual_test_range = current_range.Offset(0, x).address current_range.Offset(0, x).Formula = "=if(" & current_range.Offset(0, x).address & "= "APPLES",1,0)" x = x + 1 Loop Until x = 60 End Sub


The idea is that if the cell in current range = "APPLES" then return 1 else return 0


I cannot get this to work as VBA won't accept "APPLES" where it is currently located and I don't know how to construct a string for the formula out of variables and hard coded strings.


Please help.


Thanks.



asked 30 secs ago







creating a formula string in VBA using part formula and part hard coded string

Aucun commentaire:

Enregistrer un commentaire