Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Find text in colunn Then count rows with data

Hopefully, all the typos are gone and the omissions have been added in. I
did a full test on this one and it listed all of the data correctly. I did
not include the naming of the new workbook nor saving it since you gave no
indication that it would always be the same. You can handle that manually.
One thing to remember is that it will create a new workbook each time it is
run, NOT the same workbook over and over..

Sub countRows()
Dim rc As Long, lr As Long, lr2 As Long
Dim c As Range, NewBk As Workbook, rng As Range
Dim myFolder As String, sh As Worksheet, wb As Workbook
Set NewBk = Workbooks.Add
For Each wb In Application.Workbooks
If wb.Name < NewBk.Name Then
For Each sh In wb.Worksheets
rc = 0
lr = sh.Cells(Rows.Count, 3).End(xlUp).Row
Set c = sh.Cells.Find("Surname", LookIn:=xlValues)
If Not c Is Nothing Then
Set rng = Range("C" & c.Row + 1 & ":C" & lr)
rc = rng.Rows.Count
End If
With NewBk.Sheets(1)
lr2 = NewBk.Sheets(1) _
.Cells(Rows.Count, 1).End(xlUp).Row
If .Range("A2") = "" Then
.Range("A2") = wb.Name
.Range("B2") = sh.Name
.Range("C2") = rc
Else
.Range("A" & lr2 + 1) = wb.Name
.Range("B" & lr2 + 1) = sh.Name
.Range("C" & lr2 + 1) = rc
End If
End With
Next
End If
Next

End Sub


"Diddy" wrote in message
...


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 155
Default Find text in colunn Then count rows with data

Hope you get the reply because it has been a couple of days since I logged in
- thank you so much
Diddy

"JLGWhiz" wrote:

Hopefully, all the typos are gone and the omissions have been added in. I
did a full test on this one and it listed all of the data correctly. I did
not include the naming of the new workbook nor saving it since you gave no
indication that it would always be the same. You can handle that manually.
One thing to remember is that it will create a new workbook each time it is
run, NOT the same workbook over and over..

Sub countRows()
Dim rc As Long, lr As Long, lr2 As Long
Dim c As Range, NewBk As Workbook, rng As Range
Dim myFolder As String, sh As Worksheet, wb As Workbook
Set NewBk = Workbooks.Add
For Each wb In Application.Workbooks
If wb.Name < NewBk.Name Then
For Each sh In wb.Worksheets
rc = 0
lr = sh.Cells(Rows.Count, 3).End(xlUp).Row
Set c = sh.Cells.Find("Surname", LookIn:=xlValues)
If Not c Is Nothing Then
Set rng = Range("C" & c.Row + 1 & ":C" & lr)
rc = rng.Rows.Count
End If
With NewBk.Sheets(1)
lr2 = NewBk.Sheets(1) _
.Cells(Rows.Count, 1).End(xlUp).Row
If .Range("A2") = "" Then
.Range("A2") = wb.Name
.Range("B2") = sh.Name
.Range("C2") = rc
Else
.Range("A" & lr2 + 1) = wb.Name
.Range("B" & lr2 + 1) = sh.Name
.Range("C" & lr2 + 1) = rc
End If
End With
Next
End If
Next

End Sub


"Diddy" wrote in message
...



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
Find text in columnThen count rows with data Diddy Excel Programming 7 August 30th 09 11:57 PM
Find A value in a column and count the rows KWhamill Excel Programming 1 July 22nd 08 11:24 AM
Find a value and count the rows back to the reference row. dlbeiler Excel Worksheet Functions 8 October 11th 07 07:40 PM
Find & Count text within a cell ernie Excel Programming 2 June 5th 07 04:18 PM
Find and Count Frequency of Numeric Value in Non-Contiguous Rows Sam via OfficeKB.com Excel Worksheet Functions 2 September 17th 06 09:17 PM


All times are GMT +1. The time now is 11:12 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"