Hi all,
Dying here (First thread yay), I am dealing with a lot of functions which uses different sheets for the same purpose so I had to define some sheet with a variable (not sure if I said it correctly I'm bad with the terms).
tldr: Need to vlookup data from a defined sheet (and not by using the sheet's name) for a formula in active sheet with vba.
For example:
Public calc As Worksheet 'define sheet
Sub setcalc()
Set calc As Sheets("DataSet3") 'set sheet
Sheets("DataSet6").Activate
Range("C2").Formula = "=IFERROR(IF(VLOOKUP($A2&C$1,calc!$C:$C,1,FALSE)=DataSet6!$A2&C$1,""x""),"""")" 'you can ignore what the formula is for
'before you say "why not just put "DataSet3!" instead of "calc!" well like I said it's for lots of function I'm putting this as an example
Set calc As Sheets("DataSet4") 'set sheet
Sheets("DataSet7").Activate
Range("C2").Formula = "=IFERROR(IF(VLOOKUP($A2&C$1,calc!$C:$C,1,FALSE)=DataSet7!$A2&C$1,""x""),"""")"
End Sub
calc! doesn't seem to work as "xxx!" can only be used when referencing to a sheet name (correct me if I'm wrong). How would I be able to use the defined calc Worksheet's value in the formula?
Not sure if anyone had post about this before because I don't know how to search for this problem. Any help is well appreciated, thanks!!
Dying here (First thread yay), I am dealing with a lot of functions which uses different sheets for the same purpose so I had to define some sheet with a variable (not sure if I said it correctly I'm bad with the terms).
tldr: Need to vlookup data from a defined sheet (and not by using the sheet's name) for a formula in active sheet with vba.
For example:
Public calc As Worksheet 'define sheet
Sub setcalc()
Set calc As Sheets("DataSet3") 'set sheet
Sheets("DataSet6").Activate
Range("C2").Formula = "=IFERROR(IF(VLOOKUP($A2&C$1,calc!$C:$C,1,FALSE)=DataSet6!$A2&C$1,""x""),"""")" 'you can ignore what the formula is for
'before you say "why not just put "DataSet3!" instead of "calc!" well like I said it's for lots of function I'm putting this as an example
Set calc As Sheets("DataSet4") 'set sheet
Sheets("DataSet7").Activate
Range("C2").Formula = "=IFERROR(IF(VLOOKUP($A2&C$1,calc!$C:$C,1,FALSE)=DataSet7!$A2&C$1,""x""),"""")"
End Sub
calc! doesn't seem to work as "xxx!" can only be used when referencing to a sheet name (correct me if I'm wrong). How would I be able to use the defined calc Worksheet's value in the formula?
Not sure if anyone had post about this before because I don't know how to search for this problem. Any help is well appreciated, thanks!!