countif blank

itlsbu

Board Regular
Joined
Jul 2, 2002
Messages
102
hello,

I have a macro containing this code
Range("a4").Select
ActiveCell.FormulaR1C1 = "=COUNTIF(R[1]C:R[" & x & "]C," & y & ")"

Where
x = 6
and y = " "

this should result in de formula countif(a5:a10;"") however it doen't

How do I add a blank to this kind of string?

thanx
steven
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Well, the first tthing I would like to point out is that your message states that y = " "... or, y = [space]. Not a blank, as you state.

another way of getting the blank you expect into the formula might be
Code:
Range("a4").FormulaR1C1 = "=COUNTIF(R[1]C:R[" & x & "]C," & chr(34) & chr(34) & ")"

Though another way is to simply use the appropriate number of quotes to force-feed VBA to get them into the formula (not a big fan of it myself, so I will leave that syntax to others).

Also note that you not need to select a cell to manipulate it... observe the difference between my syntax and yours.
 
Upvote 0
thank yout very much
worked as expected

I think a tried a zillion ways of putting those quotes in, it never worked...

ps I realize my code can be a lot shorter (more efficient, faster), but what starts as a simple 4-line code, becomes a 4 kilo encyclopedia once a start adding a another great routine...

thanks and cheers Steven
 
Upvote 0

Forum statistics

Threads
1,214,790
Messages
6,121,607
Members
449,037
Latest member
Arbind kumar

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