findNEXT should be faster. See my code.

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguille...@gmail.com

From: JLO 
Sent: Saturday, June 16, 2012 8:03 AM
To: excel-macros@googlegroups.com 
Subject: Re: $$Excel-Macros$$ change content of cell across multiple worksheets

David, you're a Star!  Thank you so much - didn't expect the counter addition - 
very thoughtful of you.  It works brilliantly!
Orange on its way...! :-)

On Saturday, June 16, 2012 12:05:30 PM UTC+1, David Grugeon wrote:
  Final version including force uppercase input and counter so you know what it 
has done 

  Completed with Ucase and Counter. 

  Sub UpdateCode()

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

  mySearch = UCase(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
          Counter = Counter + 1
          
      End If
  Next c
  End If
  Next ws
  MsgBox "Made " & Counter & " Replacements", vbOKOnly, "Completed"
  End Sub

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

    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





  -- 
  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

-- 
-- 
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