VBA - Input cell formula from another cells value?

30136353

Board Regular
Joined
Aug 14, 2019
Messages
105
HI All,

I am removing a bunch of lookups in a workbook and converting them into macro formulas to speed the workbook up. I have the desired formulas in a cell, and would like to reference them to input the formula. For Example see code below. It works for must of them but doesnt seem to work when some of formulas refer to "" ("""" in VBA). Is .value the best or is there an alterative?

Thanks.

VBA Code:
    LR = Worksheets("OCR Issues").Cells(Rows.Count, 1).End(xlUp).Row

    OCR.Range("B3:C" & LR).Formula = "=" & Mac.Cells(6, 2).Value
    OCR.Range("D3:D" & LR).Formula = "=" & Mac.Range("D6:D6").Value
    OCR.Range("E3:G" & LR).Formula = "=" & Mac.Range("E6:E6").Value
    OCR.Range("H3:H" & LR).Formula = "=" & Mac.Range("H6:H6").Value
    OCR.Range("I3:I" & LR).Formula = "=" & Mac.Range("I6:I6").Value
    OCR.Range("J3:J" & LR).Formula = "=" & Mac.Range("J6:J6").Value
    OCR.Range("K3:K" & LR).Formula = "=" & Mac.Range("K6:K6").Value
    OCR.Range("L3:L" & LR).Formula = "=" & Mac.Range("L6:L6").Value
    OCR.Range("M3:N" & LR).Formula = "=" & Mac.Range("M6:M6").Value
    OCR.Range("O3:O" & LR).Formula = "=" & Mac.Range("O6:O6").Value
    OCR.Range("Q3:Q" & LR).Formula = "=" & Mac.Range("Q6:Q6").Value
    OCR.Range("R3:R" & LR).Formula = "=" & Mac.Range("R6:R6").Value
    OCR.Range("S3:S" & LR).Formula = "=" & Mac.Range("S6:A6").Value
    OCR.Range("T3:T" & LR).Formula = "=" & Mac.Range("T6:T6").Value
    OCR.Range("U3:U" & LR).Formula = "=" & Mac.Range("U6:U6").Value
    OCR.Range("V3:V" & LR).Formula = "=" & Mac.Range("V6:V6").Value
    OCR.Range("W3:AA" & LR).Formula = "=" & Mac.Range("W6:W6").Value
    OCR.Range("AB3:AB" & LR).Formula = "=" & Mac.Range("ab6:AB6").Value
    OCR.Range("AC3:AC" & LR).Formula = "=" & Mac.Range("AC6:AC6").Value
    OCR.Range("AD3:AD" & LR).Formula = "=" & Mac.Range("AD6:AD6").Value
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
What exactly is in the formula cells that don't work?
 
Upvote 0
What exactly is in the formula cells that don't work?
This doesn't work:

IF(OR(U3<>"""",""Not Complete"",V3<>""""),""YES"",""NO"")

If I input the formula directly into the VBA code it works fine... There is about 5 or 6 from the lines that dont work
 
Upvote 0
You don't need to double up the quotes in the cells. You only need to do that when you type a literal formula string into the code.
 
Upvote 0

Forum statistics

Threads
1,214,907
Messages
6,122,185
Members
449,071
Latest member
cdnMech

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