Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Countif Formula /Sort Bug??? | Excel Discussion (Misc queries) | |||
COUNTIF or not to COUNTIF on a range in another sheet | Excel Worksheet Functions | |||
COUNTIF help | Excel Worksheet Functions | |||
Combining IF and COUNTIF based on two columns | Excel Discussion (Misc queries) | |||
Countif - Countif | Excel Worksheet Functions |