+ Reply to Thread
Results 1 to 2 of 2

Macro to copy & paste values for every cell in the workbook containing a specific formula

  1. #1
    Registered User
    Join Date
    09-21-2015
    Location
    NC
    MS-Off Ver
    2013
    Posts
    1

    Macro to copy & paste values for every cell in the workbook containing a specific formula

    Hi all I have created the following macro, which effectively finds and replaces any specified formula, but I can't seem to get it to loop through every sheet in the workbook. Although i'm familiar with the common sheet loop Dim sh As Worksheet
    For Each sh In Worksheets
    'do something here
    msgbox sh.Name
    Next sh

    In my code you won't find any effort to loop through the sheets, because all attempts have failed. See code below:

    Thanks for your help!

    Sub AB()
    Dim ws As Worksheet
    Dim WhatToFind As Variant
    Dim iCtr As Long


    WhatToFind = Array("round", "sumif", "sumifs", "vlookup", "sumproduct", "today")
    For iCtr = LBound(WhatToFind) To UBound(WhatToFind)
    With rng

    Set rng = Cells.Find(What:=WhatToFind(iCtr), _
    After:=ActiveCell, LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, _
    SearchDirection:=xlNext, _
    MatchCase:=False)

    If Not rng Is Nothing Then
    Do
    rng.Formula = rng.Value
    Set rng = Cells.FindNext(rng)
    Loop Until rng Is Nothing

    End If
    End With
    Next
    End Sub

  2. #2
    Forum Expert Alf's Avatar
    Join Date
    03-13-2004
    Location
    Gothenburg/Mullsjoe, Sweden
    MS-Off Ver
    Excel 2019 and not sure I like it
    Posts
    4,758

    Re: Macro to copy & paste values for every cell in the workbook containing a specific form

    Perhaps like this?

    Please Login or Register  to view this content.
    Alf

+ 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. Loop through all sheets and copy and paste values for specific formula
    By SAFC in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-17-2015, 08:17 AM
  2. Macro to Copy/Paste History in specific worksheet, password protect workbook
    By gaker10 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-27-2015, 02:58 PM
  3. [SOLVED] Copy paste values to another workbook based on multiple cell values
    By Bazinga in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-23-2014, 12:41 PM
  4. Macro to copy data from specific columns and paste to new workbook
    By jcs2811 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2014, 10:15 PM
  5. [SOLVED] Macro to copy a specific cell and paste in another cell, for all sheets in workbook
    By lyoung1124 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-02-2014, 10:15 AM
  6. Macro to copy specific line from text file and paste into specific cell in excel
    By keeneye in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 10:35 AM
  7. Macro - Copy Specific Cells in 1 workbook and paste in another.
    By liybpg in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 07-23-2012, 10:55 AM

Tags for this Thread

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