View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Toppers Toppers is offline
external usenet poster
 
Posts: 4,339
Default code to find stuff in each sheet?

Hi,
Simple example of using FIND on column P. If you have multiple
criteria then you will probably use IF ..THEN .. ELSE constructs rather than
(or in conjunction with ) FIND.

Without knowing your criteria it is difficult to more specific.

HTH

Private Sub Worksheet_Activate()
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets
myValue = "ABC"
With sh.Columns("P:P")
' example of FIND ......look for "ABC" and replace by "XYZ"
Set c = .Find(myValue, LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
' your code here
c.Value = "XYZ"
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
Next

End Sub

" wrote:

I want to write some code to loop through all the w/sheets in the
current open workbook and inspect various columns within each sheet.

I understand how to define and loop through the worksheet collection, I
just don't know how to code the 'inspection' part ... so I've got the
outline as follows:

Private Sub Worksheet_Activate()
Dim sh As Worksheet

For Each sh In ActiveWorkbook.Worksheets
... my code to inspect, for example, column P within the wsheet
defined by sh and return a value based on various criteria

Next

but not the detail.

Anyone help....