Boogerbut74
New Member
- Joined
- Oct 17, 2022
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
I am very new to macros and VBA coding; right now, I'm having trouble with the code below. I'm trying to get it to do any row without changing the equation every time. So the C+ Active Cell.Row gets put in as an actual cell, same with F, then it's just looking at the q3 batch in these coulombs to find the exact match or next highest and gives me the data I want. Right now, though, I keep getting VBA Type Mismatch Error (Error 13), and I don't know how to fix it. I've been trying for a couple of hours now, and I'm just going down rabbit holes. I'm assuming my problem comes from quoting the C out and adding the ActiveCell.Row but I don't know how else to do this. I've put the line that's giving me problems bellow in red.
Sub Gmacro()
'
' Gmacro Macro
'
'
ActiveCell.Formula = "=XLOOKUP(C" + ActiveCell.Row + " & F" + ActiveCell.Row + ",'Q3 Batch Historian'!$A$1:A5045&'Q3 Batch Historian'!$C$1:C5045,ROW('Q3 Batch Historian'!$C$1:C5045), N/A,0,1)"
Range(ActiveCell).Select
End Sub
Sub Gmacro()
'
' Gmacro Macro
'
'
ActiveCell.Formula = "=XLOOKUP(C" + ActiveCell.Row + " & F" + ActiveCell.Row + ",'Q3 Batch Historian'!$A$1:A5045&'Q3 Batch Historian'!$C$1:C5045,ROW('Q3 Batch Historian'!$C$1:C5045), N/A,0,1)"
Range(ActiveCell).Select
End Sub