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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
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

Forum statistics

Threads
1,223,893
Messages
6,175,248
Members
452,623
Latest member
cliftonhandyman

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