#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
xxbenxx
 
Posts: n/a
Default Countif in VBA


hi, i have this countif formula that i need it to run thru all the rows
of data..

=COUNTIF(A1:A3772,"<"&A*) where * range from 1 to 1000

i wrote the following vba code but it give an 'application defined or
object defined error'


Code:
--------------------

Sub fill()
Dim irow, lastrow As Integer
Dim frmla As String

lastrow = ActiveSheet.UsedRange.Rows.Count
For irow = 1 To lastrow
frmla = "=COUNTIF(A1:A" & lastrow & ",<&A" & irow & ")"
ActiveSheet.Cells(irow, 4).Formula = frmla
Next irow

End Sub

--------------------


anyone knows where went wrong?


--
xxbenxx
------------------------------------------------------------------------
xxbenxx's Profile: http://www.excelforum.com/member.php...o&userid=30884
View this thread: http://www.excelforum.com/showthread...hreadid=507587

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Countif in VBA

You have to double up those quotes in your strings:

frmla = "=COUNTIF(A1:A" & lastrow & ",""<""&A" & irow & ")"

xxbenxx wrote:

hi, i have this countif formula that i need it to run thru all the rows
of data..

=COUNTIF(A1:A3772,"<"&A*) where * range from 1 to 1000

i wrote the following vba code but it give an 'application defined or
object defined error'

Code:
--------------------

Sub fill()
Dim irow, lastrow As Integer
Dim frmla As String

lastrow = ActiveSheet.UsedRange.Rows.Count
For irow = 1 To lastrow
frmla = "=COUNTIF(A1:A" & lastrow & ",<&A" & irow & ")"
ActiveSheet.Cells(irow, 4).Formula = frmla
Next irow

End Sub

--------------------

anyone knows where went wrong?

--
xxbenxx
------------------------------------------------------------------------
xxbenxx's Profile: http://www.excelforum.com/member.php...o&userid=30884
View this thread: http://www.excelforum.com/showthread...hreadid=507587


--

Dave Peterson
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 /Sort Bug??? orcfodder Excel Discussion (Misc queries) 2 January 12th 06 10:04 AM
COUNTIF or not to COUNTIF on a range in another sheet Ellie Excel Worksheet Functions 4 September 15th 05 10:06 PM
COUNTIF help Ant Excel Worksheet Functions 4 August 10th 05 09:02 PM
Combining IF and COUNTIF based on two columns maxtrixx Excel Discussion (Misc queries) 5 March 31st 05 06:21 PM
Countif - Countif maswinney Excel Worksheet Functions 3 November 15th 04 11:06 PM


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