Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default using countif into a formula

I want to put a formula in a cell, to check if a range of cells
contains one character.
I think it seems like

ActiveCell.Formula = "=" & "COUNTIF(" & first_cell & ":" & last_cell &
";" & ""P"" & ")"

where first_cell and last_cell are the bounds of a range
and "P" is the character I want to check if it exists

but it does not work

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default using countif into a formula

This worked for me
;-)

Dim myRange As Range
Dim Formula As String

Set myRange = Worksheets("Sheet1").Range("A1:C10")

Formula = Application.WorksheetFunction.CountIf(myRange, "P")

MsgBox Formula

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default using countif into a formula

One method is:

Sub Frmula()
Dim firstcell As String
Dim lastcell As String
firstcell = Range("A1").Address
lastcell = Range("A13").Address
Range("B1").Formula = "=COUNTIF(" & firstcell & ":" & lastcell & ",""p"")"
End Sub

Mike F

"fuzzy" wrote in message
oups.com...
I want to put a formula in a cell, to check if a range of cells
contains one character.
I think it seems like

ActiveCell.Formula = "=" & "COUNTIF(" & first_cell & ":" & last_cell &
";" & ""P"" & ")"

where first_cell and last_cell are the bounds of a range
and "P" is the character I want to check if it exists

but it does not work



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default using countif into a formula

Get the address of the cells, first_cell.address and last_cell.address

--

HTH

RP
(remove nothere from the email address if mailing direct)


"fuzzy" wrote in message
oups.com...
I want to put a formula in a cell, to check if a range of cells
contains one character.
I think it seems like

ActiveCell.Formula = "=" & "COUNTIF(" & first_cell & ":" & last_cell &
";" & ""P"" & ")"

where first_cell and last_cell are the bounds of a range
and "P" is the character I want to check if it exists

but it does not work



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Countif Formula JKVA Excel Worksheet Functions 3 December 29th 09 10:52 PM
COUNTIF FORMULA ISSUES - NEED FORMULA CORRECTED Debbi Excel Worksheet Functions 2 November 18th 09 04:47 AM
countif formula japc90 Excel Discussion (Misc queries) 6 July 25th 06 11:28 PM
CountIf formula results in the formula itself being displayed. NewKid Excel Worksheet Functions 9 December 21st 05 11:10 PM
Doing a 'countif' but I just want the value not the formula ste mac Excel Programming 3 May 15th 04 05:53 PM


All times are GMT +1. The time now is 09:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"