+ Reply to Thread
Results 1 to 4 of 4

Macro to search through button texts and replace

Hybrid View

  1. #1
    Registered User
    Join Date
    07-04-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    17

    Macro to search through button texts and replace

    I have accidentally labelled a button (form control, rather than activeX) wrong and duplicated the sheet over 50 times within the same workbook.

    I need a macro to search through all sheets and adjust the name. I have tried doing this using a few methods and to no avail.

    Hope someone can help.

  2. #2
    Registered User
    Join Date
    07-04-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: Macro to search through button texts and replace

    I have managed to create a code to rename button1 but I need to search for any button which has text "ABC" on it within the entire workbook.
    Anyone have any thoughts?

    Sub change()
    Dim btn As Shape
    For Each btn In Workbook
     Sheet1.Shapes("Button 1").TextFrame.Characters.Text = "Click Me!"
    
    End Sub

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,482

    Re: Macro to search through button texts and replace

    Sub RecaptionButtons()
        Dim shtTemp As Worksheet
        Dim shpTemp As Shape
        
        For Each shtTemp In ActiveWorkbook.Worksheets
            For Each shpTemp In shtTemp.Shapes
                If shpTemp.Type = msoFormControl Then
                    If shpTemp.OLEFormat.Object.Caption = "ABC" Then
                        shpTemp.OLEFormat.Object.Caption = "XYZ"
                    End If
                End If
            Next
        Next
        
    End Sub
    just change "ABC" and "XYZ" to suit.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    07-04-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    17

    Re: [SOLVED] Macro to search through button texts and replace

    Brilliant, thanks very much!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Macro/s to create Search Bar to filter to search terms entered activated by Command Button
    By JasonRay in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-08-2013, 03:44 PM
  2. [SOLVED] How to Find and Replace a string if cell does not contain certain texts.
    By windcloud2 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-04-2012, 01:04 PM
  3. Search and Replace macro
    By delnaja in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 09-25-2008, 06:16 AM
  4. Search and replace macro
    By timecop in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-01-2007, 08:06 AM
  5. [SOLVED] find for any of some search texts within a text
    By xirx in forum Excel General
    Replies: 2
    Last Post: 06-15-2005, 01:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1