Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
David494
 
Posts: n/a
Default Search for strings


If I use the line of code (not using vba).......
=COUNTIF(R1C1:R36C1,"COUNCIL TAX - General queries")

........ then it works fine.

However if i put this into vba using a macro then it doesn't work.

Application.WorksheetFunction.CountIf(range("R2C1: R35C1"), "COUNCIL TAX
- General queries*")


Totally stuck here,

Will keep trying, but does anyone understand this

Thanks Guys.

Dave


--
David494
------------------------------------------------------------------------
David494's Profile: http://www.excelforum.com/member.php...o&userid=24482
View this thread: http://www.excelforum.com/showthread...hreadid=391239

  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

From VBA Help (Range Property):

expression.Range(Cell1)

Cell1 Required. The name of the range. This must be an A1-style
reference in the language of the macro.


So try

Application.WorksheetFunction.CountIf(Range("A2:A3 5"), _
"COUNCIL TAX - General queries*")

In article ,
David494 wrote:

If I use the line of code (not using vba).......
=COUNTIF(R1C1:R36C1,"COUNCIL TAX - General queries")

....... then it works fine.

However if i put this into vba using a macro then it doesn't work.

Application.WorksheetFunction.CountIf(range("R2C1: R35C1"), "COUNCIL TAX
- General queries*")


Totally stuck here,

Will keep trying, but does anyone understand this

Thanks Guys.

Dave

  #3   Report Post  
David494
 
Posts: n/a
Default


but i just get the same error message.

Compile Error

Expected: =

.....I don't know what this error is.

Thanks for helping

Dave


--
David494
------------------------------------------------------------------------
David494's Profile: http://www.excelforum.com/member.php...o&userid=24482
View this thread: http://www.excelforum.com/showthread...hreadid=391239

  #4   Report Post  
David494
 
Posts: n/a
Default


Strange, it seems to work when I msgBox it.

E.g

MsgBox (Application.WorksheetFunction.CountIf(Range("A2:A 35"), "COUNCIL
TAX - General queries*"))


--
David494
------------------------------------------------------------------------
David494's Profile: http://www.excelforum.com/member.php...o&userid=24482
View this thread: http://www.excelforum.com/showthread...hreadid=391239

  #5   Report Post  
David494
 
Posts: n/a
Default


Strange, it seems to work when I msgBox it.

E.g

MsgBox (Application.WorksheetFunction.CountIf(Range("A2:A 35"), "COUNCIL
TAX - General queries*"))


--
David494
------------------------------------------------------------------------
David494's Profile: http://www.excelforum.com/member.php...o&userid=24482
View this thread: http://www.excelforum.com/showthread...hreadid=391239



  #6   Report Post  
JE McGimpsey
 
Posts: n/a
Default

In VBA, if you're not returning the value to a variable or method, you
don't use the parens (see VBA Help "Using Parentheses in Code"), so the
code would be

Application.WorksheetFunction.CountIf Range("A2:A35"), _
"COUNCIL TAX - General queries*"

but that invokes the method without any purpose. Why are you calling
CountIf if you're not going to use the result?

In article ,
David494
wrote:


but i just get the same error message.

Compile Error

Expected: =

....I don't know what this error is.

  #7   Report Post  
David494
 
Posts: n/a
Default


Sorry for not getting back to you sooner, but i forgot all about this
post. The message box does me fine, as i just want the user to know
the number of times a string appears between two specified dates, then
they can note down this value.

Thanks for your help

Dave


--
David494
------------------------------------------------------------------------
David494's Profile: http://www.excelforum.com/member.php...o&userid=24482
View this thread: http://www.excelforum.com/showthread...hreadid=391239

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
Wildcard search functions within Vlookup Benn Excel Worksheet Functions 2 July 26th 05 01:12 PM
Criteria search function Corey Excel Discussion (Misc queries) 2 June 16th 05 10:34 PM
Find and search by column Brian Excel Discussion (Misc queries) 8 May 13th 05 12:35 AM
FAQ Spreadsheet with search function murphyz Excel Discussion (Misc queries) 0 March 19th 05 09:24 PM
can i make a formula to search keywords in a excel workbook? gorillayam Excel Worksheet Functions 0 January 15th 05 02:25 AM


All times are GMT +1. The time now is 08:44 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"