PDA

View Full Version : Syntaxes for Worksheets and RC formula



Hal9va
12-01-2010, 05:43 PM
Hi,

I have a piece of code that I want to change but I do not know the right syntaxes. I have searched the web and could not find it.

If rw1Row > rw2Row _
Then
Set Rng1 = Range("A" & rFDRow) 'Setting a Range 1
Rng1.FormulaR1C1 = "=IF(old!RC<>new!RC, ""Don't Match"", old!RC)"
Rng1.Copy Destination:=Rng1.Resize(rw1Row - 3, 19)
Rng1.Copy Destination:=Range("AB" & rFDRow).Resize(rw1Row - 3, 4)


New and Old are the names of the two worksheets. Theses worksheets are presented in the certain order/sequence. (New is worksheet 1, Old is worksheet 2). I want this code to implement the formula without using the names of the worksheets. Just referring to the sheets.

"=IF(" & Sheets(1).Name & "!RC <>" & Sheets(2).Name & "!RC," "Don't Match," & Sheets(1).Name & "!RC")"

I tried this combination and other, but still does not work.

Thanks a lot

mbarron
12-01-2010, 07:40 PM
Try this version:
"=IF(" & Sheets(2).Name & "!RC <>" & Sheets(1).Name & "!RC,""Don't Match""," & Sheets(2).Name & "!RC)"

Hal9va
12-02-2010, 12:23 PM
Thanks a lot!!! :)