Having Macros set a formula based on string formula

Breakingb0xes

New Member
Joined
May 4, 2018
Messages
2
I have a macros I'm writing and I have it a snag. I have the macros create a formula that uses a last name from a designated column. However when it places the formula in the cell, it displays FALSE in the cell, but when I click on the cell it displays the formula I want, it just will not act as a formula. The sub routine is posted below.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim New_set As String
New_set = Range("A12")
Dim Hours
Hours = "=IF(Last!$B$6>0,(Last!$B$6-Last!$B$5)-SUM(Last!$B$7:$B$10),(IF(Last!$B$5="","",$C$1-Last!$B$5-SUM(Last!$B$7:$B$10))))"
If New_set = "Load Formulas" Then
For i = 13 To 17
Dim LastN
Dim p
LastN = Cells(i, 2)
p = Mid(LastN, 1, InStr(1, LastN, ",") - 1)
Cells(i, 3).FormulaArray = Replace(Hours, "Last", p)
Next i
End If
Range("A12") = " "
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I can't see why you are entering this as an array formula, try changing:
Cells(i, 3).FormulaArray = Replace(Hours, "Last", p)
to
Code:
[COLOR=#333333]Cells(i, 3).Formula = Replace(Hours, "Last", p)[/COLOR]
 
Upvote 0
I can't see why you are entering this as an array formula, try changing:

to
Code:
[COLOR=#333333]Cells(i, 3).Formula = Replace(Hours, "Last", p)[/COLOR]

I tried it both ways, and both will place the correct formula but it still acts as a string.
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top