Sorry - hit the send button too quickly

Option Explicit

Sub UpdateCode()

Dim mySearch As String
Dim myReplaceValue As String
Dim ws As Worksheet
Dim c As Range

mySearch = InputBox("Enter the Box Number requiring relocation: ")
myReplaceValue = InputBox("What is the new location? ")

For Each ws In Worksheets
If Len(ws.Name) = 1 Then
For Each c In Intersect(ws.Range("O:O"), ws.UsedRange)
    If c.Value = mySearch Then
        c.Offset(0, 4) = myReplaceValue

    End If
Next c
End If
Next ws
End Sub

On 16 June 2012 12:10, David Grugeon <da...@grugeon.com.au> wrote:

> Hi Jeanette
>
> Try the following.  It assumes that the sheet names of 1 character length
> are the ones you want to work with.  If this is not so you will need to
> change the line
>
> If Len(ws.Name) = 1 Then
>
> to apply a more appropriate test.
>
> On 16 June 2012 10:18, JLO <jeanette_lovel...@btinternet.com> wrote:
>
>> Could really use some help with this.  I have worksheets A to Z.  I'm
>> searching for data the user has entered via an input box, then changing the
>> data in cells over to the right with the data the user enters via another
>> input box.  This works perfectly on active sheet.  What I need is for the
>> exact same thing to happen across worksheets A to Z (there being further
>> worksheets that don't get changed), so some sort of loop is needed.  I've
>> tried looping, but with disastrous results!! I'd really appreciate a
>> solution - I cribbed the example from elsewhere and tailored it, but I'm
>> stumped to get it to work across the other sheets.  Thanks in advance for
>> all your help!  Here's my code:
>>
>> With ActiveSheet.Range("O:O")
>>     Dim mySearch As String
>>     Dim myReplaceValue
>>     mySearch = InputBox("Enter the Box Number requiring relocation: ")
>>     myReplaceValue = InputBox("What is the new location? ")
>>     Set c = .Find(mySearch, LookIn:=xlValues)
>>     If Not c Is Nothing Then
>>         firstaddress = c.Address
>>         Do
>>             c.Offset(, 4) = myReplaceValue
>>             Set c = .FindNext(c)
>>         Loop While Not c Is Nothing And c.Address <> firstaddress
>>     End If
>> End With
>>
>> --
>> FORUM RULES (986+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5) Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE : Don't ever post personal or confidential data in a workbook. Forum
>> owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>> To unsubscribe, send a blank email to
>> excel-macros+unsubscr...@googlegroups.com
>
>
>
>
> --
> David Grugeon
>



-- 
David Grugeon

-- 
FORUM RULES (986+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

To unsubscribe, send a blank email to excel-macros+unsubscr...@googlegroups.com

Reply via email to