Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Lookup on multiple sheets in file

Hello. I have an excel workbook with 90 sheets in it. Each sheet is
identical in format and size (like a template). Somewhere between B50 and
B200 of each sheet there may or may not be in the cell the word "Payroll".
I need to remove the contents of columns C through Z on all lines that have
the word "Payroll" in column B, and do this on every sheet. Is there a
simple way to code this? Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Lookup on multiple sheets in file

You could loop through the range looking for Payroll. And when you find it,
clear those cells.

VBA has a nice example for this kind of thing.

Then you could loop through all the worksheets in your workbook.

Kind of like:

Option Explicit
Sub testme()

Dim FoundCell As Range
Dim wks As Worksheet
Dim FirstAddress As String
Dim LookForStr As String

LookForStr = "payroll"
For Each wks In ActiveWorkbook.Worksheets
With wks
FirstAddress = ""
With .Range("b:b")
Set FoundCell = .Cells.Find(what:=LookForStr, _
LookIn:=xlValues, lookat:=xlPart, _
searchorder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False)
If FoundCell Is Nothing Then
'do nothing
Else
FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Resize(1, 24).ClearContents
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End With
Next wks
End Sub


I looked for payroll anywhere in the cell in column B (xlpart).



Steph wrote:

Hello. I have an excel workbook with 90 sheets in it. Each sheet is
identical in format and size (like a template). Somewhere between B50 and
B200 of each sheet there may or may not be in the cell the word "Payroll".
I need to remove the contents of columns C through Z on all lines that have
the word "Payroll" in column B, and do this on every sheet. Is there a
simple way to code this? Thanks!


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 312
Default Lookup on multiple sheets in file

Perfect! Thanks Dave!!

"Dave Peterson" wrote in message
...
You could loop through the range looking for Payroll. And when you find
it,
clear those cells.

VBA has a nice example for this kind of thing.

Then you could loop through all the worksheets in your workbook.

Kind of like:

Option Explicit
Sub testme()

Dim FoundCell As Range
Dim wks As Worksheet
Dim FirstAddress As String
Dim LookForStr As String

LookForStr = "payroll"
For Each wks In ActiveWorkbook.Worksheets
With wks
FirstAddress = ""
With .Range("b:b")
Set FoundCell = .Cells.Find(what:=LookForStr, _
LookIn:=xlValues, lookat:=xlPart, _
searchorder:=xlByRows, searchdirection:=xlNext, _
MatchCase:=False)
If FoundCell Is Nothing Then
'do nothing
Else
FirstAddress = FoundCell.Address
Do
FoundCell.Offset(0, 1).Resize(1, 24).ClearContents
Set FoundCell = .FindNext(FoundCell)
Loop While Not FoundCell Is Nothing _
And FoundCell.Address < FirstAddress
End If
End With
End With
Next wks
End Sub


I looked for payroll anywhere in the cell in column B (xlpart).



Steph wrote:

Hello. I have an excel workbook with 90 sheets in it. Each sheet is
identical in format and size (like a template). Somewhere between B50
and
B200 of each sheet there may or may not be in the cell the word
"Payroll".
I need to remove the contents of columns C through Z on all lines that
have
the word "Payroll" in column B, and do this on every sheet. Is there a
simple way to code this? Thanks!


--

Dave Peterson



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
Lookup across multiple columns within multiple sheets Garnet Excel Discussion (Misc queries) 2 June 25th 08 11:46 PM
LOOKUP across Multiple Sheets LeeM Excel Worksheet Functions 4 June 5th 07 03:27 PM
V-Lookup from multiple sheets Byron720 Excel Discussion (Misc queries) 7 May 10th 07 06:39 AM
Lookup using multiple sheets and multiple criteria, sorry if 2 pos kjguillermo Excel Worksheet Functions 4 January 16th 07 03:21 AM
Lookup using multiple sheets and multiple criteria kjguillermo Excel Discussion (Misc queries) 2 January 14th 07 10:28 AM


All times are GMT +1. The time now is 05:24 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"