PC Review


Reply
Thread Tools Rate Thread

Counta with VBA -

 
 
=?Utf-8?B?RWR1YXJkbw==?=
Guest
Posts: n/a
 
      17th Jul 2007
I have in column A information, some of the rows contain the word "PO1"
What I need in VBA to do is to count the "PO1" and put the total below the
last row used but in column B
I need it
Thank you in advance
Eduardo
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Sm9obiBCdW5keQ==?=
Guest
Posts: n/a
 
      17th Jul 2007
here you go

Sub main()
Dim myCounter As Long
Dim lastRow As Long

'find last used cell
lastRow = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row

myCounter = 0

For i = 1 To lastRow ' set i = to the first row you want to search in
If Sheets("sheet1").Cells(i, 1) = "PO1" Then myCounter = myCounter + 1

Next

Sheets("sheet1").Cells(i, "B") = myCounter
End Sub
--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Eduardo" wrote:

> I have in column A information, some of the rows contain the word "PO1"
> What I need in VBA to do is to count the "PO1" and put the total below the
> last row used but in column B
> I need it
> Thank you in advance
> Eduardo

 
Reply With Quote
 
=?Utf-8?B?VGV4YXMgQWdnaWU=?=
Guest
Posts: n/a
 
      17th Jul 2007
If I understand you correctly, you should be able to accomplish this goal
without using a VBA code. Correct me if I am wrong, but you want to place in
a cell in column B the number of times "PO1" appears in column A.

In cell B1 place this code.

=SUM(A1:A100,IF(A1:A100="PO1",1,0))

This is an array formula so it requires that you you enclose the formula in
braces {}

Click the cell that contains the array formula (array formula: A formula
that performs multiple calculations on one or more sets of values, and then
returns either a single result or multiple results. Array formulas are
enclosed between braces { } and are entered by pressing CTRL+SHIFT+ENTER.).

That should do it.

~Ryan

--
Silverbird Designs @ www.silverbirddesigns.com

Fighting Texas Aggie Class of 2009


"Eduardo" wrote:

> I have in column A information, some of the rows contain the word "PO1"
> What I need in VBA to do is to count the "PO1" and put the total below the
> last row used but in column B
> I need it
> Thank you in advance
> Eduardo

 
Reply With Quote
 
=?Utf-8?B?S2V2aW4gSm9uZXM=?=
Guest
Posts: n/a
 
      17th Jul 2007
Place this formula in cell the last row of column B:

=COUNTIF(A:A,"*P01*")

Kevin
 
Reply With Quote
 
=?Utf-8?B?RWR1YXJkbw==?=
Guest
Posts: n/a
 
      18th Jul 2007
Hi John, works like a dream thank you so much

"John Bundy" wrote:

> here you go
>
> Sub main()
> Dim myCounter As Long
> Dim lastRow As Long
>
> 'find last used cell
> lastRow = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
>
> myCounter = 0
>
> For i = 1 To lastRow ' set i = to the first row you want to search in
> If Sheets("sheet1").Cells(i, 1) = "PO1" Then myCounter = myCounter + 1
>
> Next
>
> Sheets("sheet1").Cells(i, "B") = myCounter
> End Sub
> --
> -John
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "Eduardo" wrote:
>
> > I have in column A information, some of the rows contain the word "PO1"
> > What I need in VBA to do is to count the "PO1" and put the total below the
> > last row used but in column B
> > I need it
> > Thank you in advance
> > Eduardo

 
Reply With Quote
 
=?Utf-8?B?RWR1YXJkbw==?=
Guest
Posts: n/a
 
      19th Jul 2007
Thank you very much John, it works perfect

"John Bundy" wrote:

> here you go
>
> Sub main()
> Dim myCounter As Long
> Dim lastRow As Long
>
> 'find last used cell
> lastRow = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
>
> myCounter = 0
>
> For i = 1 To lastRow ' set i = to the first row you want to search in
> If Sheets("sheet1").Cells(i, 1) = "PO1" Then myCounter = myCounter + 1
>
> Next
>
> Sheets("sheet1").Cells(i, "B") = myCounter
> End Sub
> --
> -John
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "Eduardo" wrote:
>
> > I have in column A information, some of the rows contain the word "PO1"
> > What I need in VBA to do is to count the "PO1" and put the total below the
> > last row used but in column B
> > I need it
> > Thank you in advance
> > Eduardo

 
Reply With Quote
 
=?Utf-8?B?RWR1YXJkbw==?=
Guest
Posts: n/a
 
      19th Jul 2007
John, thank you so much for your help it works great

"John Bundy" wrote:

> here you go
>
> Sub main()
> Dim myCounter As Long
> Dim lastRow As Long
>
> 'find last used cell
> lastRow = Sheets("sheet1").Cells(Rows.Count, "A").End(xlUp).Row
>
> myCounter = 0
>
> For i = 1 To lastRow ' set i = to the first row you want to search in
> If Sheets("sheet1").Cells(i, 1) = "PO1" Then myCounter = myCounter + 1
>
> Next
>
> Sheets("sheet1").Cells(i, "B") = myCounter
> End Sub
> --
> -John
> Please rate when your question is answered to help us and others know what
> is helpful.
>
>
> "Eduardo" wrote:
>
> > I have in column A information, some of the rows contain the word "PO1"
> > What I need in VBA to do is to count the "PO1" and put the total below the
> > last row used but in column B
> > I need it
> > Thank you in advance
> > Eduardo

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: Counta Sean Timmons Microsoft Excel Misc 1 25th Sep 2008 07:13 PM
COUNTA IF(NOT) jiwolf Microsoft Excel Misc 2 25th Mar 2005 08:00 PM
counta =?Utf-8?B?cmFib2w=?= Microsoft Excel Misc 2 6th Mar 2005 05:12 PM
COUNTA Function not working =COUNTA(C3:C69,"NH") =?Utf-8?B?TWlrZWluTkg=?= Microsoft Excel Worksheet Functions 2 8th Nov 2004 01:19 AM
COUNTA R B Microsoft Excel Worksheet Functions 1 11th Sep 2004 04:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:39 PM.