VBA HELP! Adding Formula's into VBA

Fuisdale2

Board Regular
Joined
Mar 28, 2017
Messages
57
Thank you for reading my post.

I have the below formula which I would like to change into VBA code. The spreadsheet that has this code in there are 43 columns with similar formula's in them which makes the documenter slow.

Could I get your advice on how to write this as VBA code and then for the code to run and apply the formula to the cells on the spreadsheet.

=IF(Update_Report!D6<>(SDB_Data!A8),"MHL TAB:"&Update_Report!D6&" vs SDB TAB:"&SDB_Data!A8,"")
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I tried using this VBA code and it worked for simple formula. But the above gives me an error.

Range("B7:B2162").Formula = " "
 
Upvote 0
At a guess, try:
Code:
Sub Macro1()

    Dim strFrm  As String
    Dim LastRow As Long
    
    strFrm = "=IF(Update_Report!D6<>(SDB_Data!A8),@1MHL TAB:@1&Update_Report!D6&@1 vs SDB TAB:@1&SDB_Data!A8,@1@1)"
    
    LastRow = Cells(Rows.Count, 2).End(xlUp).row
    With Range("B8")
        .Formula = Replace(strFrm, "@1", """")
        .Resize(LastRow - 7).FillDown
    End With
      
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,241
Members
452,622
Latest member
Laura_PinksBTHFT

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