View Single Post
 
Old 10-27-2019, 06:15 AM
jeffreybrown jeffreybrown is offline Windows 10 Office 2016
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Place your cursor in the cell with the formula, turn on the macro recorder, press F2 and then press tab. Now turn off the macro recorder. Open up the VBE and the code will be there.

Or simply, copy and paste (Note: I also adjusted your formula a tad)

Code:
Sub MyFormula()
    Range("D1").Formula = "=IF('8'!D17<>"""",'8'!D17,""NO TEAM"")"
End Sub
Notice, anytime you have quotes in VBA they need to be doubled up.

Also, the first method will record the formula in R1C1 notation.
Reply With Quote