bcarter001
New Member
- Joined
- Feb 8, 2022
- Messages
- 2
- Office Version
- 2016
- Platform
- 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!
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