VBA Macro will post formula incorrectly

bcarter001

New Member
Joined
Feb 8, 2022
Messages
2
Office Version
  1. 2016
Platform
  1. Windows
Hello everyone. I am using a macro to consolidate two files and have the information referenced between two sheets, but when the macro is supposed to paste a formula {=IFERROR(VLOOKUP(B6,GTN!A:C,2,FALSE),""}, what I end up getting is a different one {=IFERROR(VLOOKUP('B6',GTN!A:M:M,2,FALSE),"")}

I'm not sure what's causing the error, as the macro literally states the former code and the M:M seems to be coming from nowhere. I've pasted my entire code below. Please help if you are able. Thank you!

Excel Formula:
Sub InforNexusWeightStart()
'
' InforNexusWeightStart Macro
' Gets the weight research report started
'
' Keyboard Shortcut: Ctrl+Shift+N
    '
    ' Grab info from another file
    '
    Windows("SKU+Weights+.xlsx") _
        .Activate
    Sheets("Page 1").Select
    Sheets("Page 1").Copy After:=Workbooks( _
        "FTZ SKU's.xlsx").Sheets(1)
    '
    ' Rename sheet to work with formula
    '
    Sheets("Page 1").Select
    Sheets("Page 1").Name = "GTN"
        Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=False, FieldInfo _
        :=Array(1, 1), TrailingMinusNumbers:=True
    '
    ' Set up the new formulas
    '
    Sheets("FTZ SKU's with 999 Weight Repor").Select
    Range("M6").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(VLOOKUP(B6,GTN!A:C,2,FALSE),"""")"
    Range("N6").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(VLOOKUP(B6,GTN!A:C,3,FALSE),""Not on GTN - Ignore"")"
    Range("M6").Select
    Selection.AutoFill Destination:=Range("M6:M20000")
    Range("M6:M20000").Select
    Range("N6").Select
    Selection.AutoFill Destination:=Range("N6:N20000")
    Range("N6:N20000").Select
    '
    ' Add the labels to the end of the report
    '
    Range("M5").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 12632256
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    ActiveCell.FormulaR1C1 = "Nexus WGT"
    Range("N5").Select
    With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 12632256
        .TintAndShade = 0
        .PatternTintAndShade = 0
    End With
    ActiveCell.FormulaR1C1 = "Nexus WGT UOM"
    Range("M5:N5").Select
    Selection.AutoFilter
End Sub
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi & welcome to MrExcel.
You need to change FormulaR1C1 to just Formula
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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