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

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
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,216,102
Messages
6,128,853
Members
449,471
Latest member
lachbee

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