View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Sjakkie Sjakkie is offline
external usenet poster
 
Posts: 23
Default worksheet loop

sorry, this is all toatally new and i am trying to understand it more. Could
you input the code where it is suppossed to go and what to replace.... it
would be much appreciatted.



"Don Guillett" wrote:


for each ws in worksheets
if ws.name < "Sheet1" and ws. name < "Sheet2" then
with ws
.. 'watch your dot placement
end with
next ws

--
Don Guillett
SalesAid Software

"Sjakkie" wrote in message
...
how can i adapt the following script to run on all worksheets in a
workbook
but to ignore and go to the next sheet if the sheet name equals "Sheet1"
or
"Sheet2"

Public Sub Processteams()
Dim iLastRow As Long
Dim i As Long
Dim iCol As Long
Dim iRow As Long
With ActiveSheet


Rows("1:300").Insert Shift:=xlToRight
iLastRow = .Cells(.Rows.Count, "o").End(xlUp).Row
For i = 1 To iLastRow
iCol = 0
On Error Resume Next
iCol = Application.Match(.Cells(i, "o").Value, _
ActiveSheet.Rows(1), 0)
On Error GoTo 0
If iCol = 0 Then
iCol = ActiveSheet.Range("a1").End(xlToRight).Column + 1
If iCol .Columns.Count Then
iCol = IIf(ActiveSheet.Range("a1").Value = "", 1, 2)
End If
ActiveSheet.Cells(1, iCol).Value = .Cells(i, "o").Value
iRow = 2
ActiveSheet.Cells(1, iCol).Interior.ColorIndex = 37
Else
iRow = ActiveSheet.Cells(1, iCol).End(xlDown).Row + 1
End If
ActiveSheet.Cells(iRow, iCol).Value = .Cells(i, "c").Value
Next i
End With
End Sub