Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
vt7 vt7 is offline
external usenet poster
 
Posts: 2
Default Macro that searches 5 files .xls and in every worksheet in every file is looking for "text".

Hi,
I am rather novice user of Excel VBA. My "macro" problem is:
1. Open 5 .xls files.
2. In every worksheet of every file check if Range("A1").Value is
"Text"
3. Close 5 .xls files.
4. Print the results of searching f.e. "I have found "Text" 56 times."
in new workbook.

Please help...
I'm looking forward to hearing from you :)

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro that searches 5 files .xls and in every worksheet in every file is looking for "text".

Sub ProcessFiles()
Dim nItems As Long

nItems = CountTests("C:\myNew\010212.xls", "Text") + _
CountTests("C:\myNew\010306.xls", "Text") + _
CountTests("C:\myNew\020309.xls", "Text") + _
CountTests("C:\myNew\030902.xls", "Text") + _
CountTests("C:\myNew\ABC.xls", "Text")

Workbooks.Add
ActiveSheet.Range("A1").Value = nItems
End Sub

Private Function CountTests(wbName As String, _
lookup_val As String) As Long
Dim oWS As Worksheet

Workbooks.Open wbName
For Each oWS In ActiveWorkbook.Worksheets
If oWS.Range("A1").Value = lookup_val Then
CountTests = 1
End If
Next
ActiveWorkbook.Close savechanges:=False

End Function


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"vt7" wrote in message
oups.com...
Hi,
I am rather novice user of Excel VBA. My "macro" problem is:
1. Open 5 .xls files.
2. In every worksheet of every file check if Range("A1").Value is
"Text"
3. Close 5 .xls files.
4. Print the results of searching f.e. "I have found "Text" 56 times."
in new workbook.

Please help...
I'm looking forward to hearing from you :)



  #3   Report Post  
Posted to microsoft.public.excel.programming
vt7 vt7 is offline
external usenet poster
 
Posts: 2
Default Macro that searches 5 files .xls and in every worksheet in every file is looking for "text".


It works perfectly with a small correction:

' CountTests = 1
CountTests = Countests + 1 ,

Thank you very much for your help !!!!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro that searches 5 files .xls and in every worksheet in every file is looking for "text".

Sorry for that type

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"vt7" wrote in message
oups.com...

It works perfectly with a small correction:

' CountTests = 1
CountTests = Countests + 1 ,

Thank you very much for your help !!!!!



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default Macro that searches 5 files .xls and in every worksheet in every file is looking for "text".

Roedd <<Bob Phillips wedi ysgrifennu:

Sorry for that type


typo? ;-)

Rob




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Macro that searches 5 files .xls and in every worksheet in every file is looking for "text".

Proves my point <bg

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Roedd <<Bob Phillips wedi ysgrifennu:

Sorry for that type


typo? ;-)

Rob




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
text string: "91E10" in csv file auto converts to: "9.10E+11" [email protected] Excel Discussion (Misc queries) 2 August 12th 08 03:13 PM
VLOOKUP gives duplicate results for "empty" searches Doc Farmer Excel Worksheet Functions 4 April 5th 07 10:19 AM
.csv drops "0" when saved, even if file was set as "text". TRminator Excel Discussion (Misc queries) 3 November 2nd 05 02:11 PM
Sending macro based e-mail with built-in "Heading" and "Text" Prabha Excel Programming 3 January 17th 05 02:11 PM
How to use macro to rename worksheet with date +"text" Sherri[_3_] Excel Programming 4 April 28th 04 12:05 AM


All times are GMT +1. The time now is 02:37 AM.

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"