Single quote disappearing

jkicker

Board Regular
Joined
Jun 7, 2018
Messages
79
what i have:
Code:
ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(MATCH(R[0]C[-1],'Hierarchy'!B:B,0))," & Chr(34) & "Exist" & Chr(34) & "," & Chr(34) & "No" & Chr(34) & ")"

What i want:
=IF(ISNUMBER(MATCH(G2,'Hierarchy'!B:B,0)),"Exist","No")

What i'm getting:
=IF(ISNUMBER(MATCH(G2,Hierarchy!B:(B),0)),"Exist","No")

The single quotes around the sheet name are disappearing. i have tried:
Code:
ActiveCell.FormulaR1C1 =  "=IF(ISNUMBER(MATCH(R[0]C[-1]," & Chr(39) & "Hierarchy" & Chr(39) &  "!B:B,0))," & Chr(34) &  "Exist" & Chr(34) & "," & Chr(34) & "No" & Chr(34)  & ")"

I get the same result. I have also tried using a public constant to no avail.

The really weird part is when I go back into my workbook and try to change the formula manually, it deletes the single quote again!
I closed all my workbooks, and reopened everything and tried writing it manually, and it worked ok, but after i execute my macro, i can't type the single quote even manually anymore.
The rest of the macro just finds a cell, adds a column next to it, puts a title on the column, and sets some variables. i can't imagine anything else in the code affecting it but i've included it on the bottom.
I'm using Excel 2013. The code is in my PERSONAL.XLSB book, the file i'm working on is not saved as macro enabled.
Help?

Code:
Sub HierarchyCheck()

Worksheets("Art Sci PERA Pre-Audit").Activate

Dim picfc As Range
Dim picfcr As Range
Dim hierchkr As Range
    Set picfc = Range("A1:AZ1").Find("PICFC").Offset(1, 0)
    Set picfcr = Range(picfc, picfc.End(xlDown))
    
    Range("A1:AZ1").Find("PICFC").Select
    ActiveCell.EntireColumn.Offset(0, 1).Insert
    
    Set hierchkr = picfcr.Offset(0, 1)
    
    ActiveCell.Offset(0, 1).Select
    ActiveCell.Formula = "In FAS Hierarchy?"
    ActiveCell.Offset(1, 0).Select
    ActiveCell.FormulaR1C1 = "=IF(ISNUMBER(MATCH(R[0]C[-1],'Hierarchy'!B:B,0))," & Chr(34) & "Exist" & Chr(34) & "," & Chr(34) & "No" & Chr(34) & ")"
    Selection.AutoFill Destination:=hierchkr, Type:=xlFillDefault
    

End Sub
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Wow i didn't notice those out of place brackets until i posted this and it made emoji sad faces. More mysteries...
 
Upvote 0
You don't always need the single quote, so Xl removes them when they are irrelevant.
 
Upvote 0
So the brackets were appearing because i was using R1C1 format and calling the columns by name. I changed B:B to C2:C2 and it fixed the problem. My formula still doesn't show the single quotes, but the formula works.
 
Upvote 0
You don't always need the single quote, so Xl removes them when they are irrelevant.

So if i named my sheet for instances FAS Hierarchy, with a space, then the single quotes would appear?
...
Confirmed. They do appear in this instance. Thanks Fluff
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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