Count Specific words from all the sheet.

SHEEPRAL

New Member
Joined
Mar 19, 2017
Messages
16
Dear All,

I am trying to build a macro to find specific words from the excel sheet with all the excel sheets available in macro.
My requirement are as below.

Need the count of that specific word in last ( summary ) sheet.
Also need a sheetwise count in single row.
Sheet name should be copied in summary sheet.

example. ( Summary Sheet )

Sheet namevishalRaghuuday
Sheet1 ( as per name given to sheet )235
Sheet2( as per name given to sheet )120

<tbody>
</tbody>

So if in Sheet1 ( Range A:A ) if Vishal name appears 2 times details in summary sheet should be as quoted above.

Hope you will assist me in creating this macro which will save my lots of time.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi, how about
Code:
Sub GetCounts()

   Dim Ary As Variant
   Dim SuSht As Worksheet
   Dim Ws As Worksheet
   Dim Cnt As Long
   Dim Rw As Long
   
   Ary = Array("[COLOR=#ff0000]vishal[/COLOR]", "[COLOR=#ff0000]raghu[/COLOR]", "[COLOR=#ff0000]uday[/COLOR]")
   Set SuSht = Sheets("Summary")
   Rw = 1
   
   SuSht.Range("B1").Resize(, UBound(Ary) + 1).Value = Ary
   For Each Ws In Worksheets
      Rw = Rw + 1
      SuSht.Range("A" & Rw).Value = Ws.name
      If Not Ws.name = "Summary" Then
         For Cnt = LBound(Ary) To UBound(Ary)
            SuSht.Cells(Rw, Cnt + 2).Value = WorksheetFunction.CountIf(Ws.Columns(1), Ary(Cnt))
         Next Cnt
      End If
   Next Ws

End Sub
Values in red are the search terms
 
Upvote 0

<tbody>
</tbody>
Dear Fluff,

Thanks a lot for your valuable help.

Sorry to disturb you again, can we add one more details in Summary sheet.
For e.g. I have similar names in another column B, and I need the details of the same too.

example. ( Summary Sheet )
A RESULTA RESULTA RESULTB RESULTB RESULTB RESULT
SHEET NAMERAGHUVISHALUDAYRAGHUVISHALUDAY
SHEET112410510

<tbody>
</tbody>
 
Upvote 0
How about
Code:
Sub GetCounts()

   Dim AryA As Variant
   Dim AryB As Variant
   Dim SuSht As Worksheet
   Dim Ws As Worksheet
   Dim CntA As Long
   Dim CntB As Long
   Dim Rw As Long
   
   AryA = Array("vishal", "raghu", "uday")
   AryB = Array("vishal", "raghu", "uday")
   Set SuSht = Sheets("Summary")
   Rw = 1
   
   SuSht.Range("B1").Resize(, UBound(AryA) + 1).Value = AryA
   SuSht.Cells(1, Columns.Count).End(xlToLeft).Offset(, 1).Resize(, UBound(AryB) + 1).Value = AryB
   For Each Ws In Worksheets
      Rw = Rw + 1
      If Not Ws.name = "Summary" Then
         SuSht.Range("A" & Rw).Value = Ws.name
         For CntA = LBound(AryA) To UBound(AryA)
            SuSht.Cells(Rw, CntA + 2).Value = WorksheetFunction.CountIf(Ws.Columns(1), AryA(CntA))
         Next CntA
         For CntB = LBound(AryB) To UBound(AryB)
            SuSht.Cells(Rw, CntA + CntB + 2).Value = WorksheetFunction.CountIf(Ws.Columns(1), AryA(CntB))
         Next CntB
      End If
   Next Ws

End Sub
 
Upvote 0

Forum statistics

Threads
1,214,650
Messages
6,120,734
Members
448,987
Latest member
marion_davis

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top