Desperationmode
New Member
- Joined
- Jan 8, 2019
- Messages
- 3
[FONT="]Hey Everyone,[/FONT]
[FONT="]I have a workbook with 60+ worksheets, and inconsistent data ranges within each. I need to create VBA code to:[/FONT]
[FONT="]Sub FindReplaceAll()[/FONT]
[FONT="]Dim sht As Worksheet[/FONT]
[FONT="]Dim fnd As Variant[/FONT]
[FONT="]Dim rplc As Variant[/FONT]
[FONT="]fnd = "*CODE*"[/FONT]
[FONT="]'I'd like to replace any cell containing containing *CODE* in the formula, with the value that the formula is calculating[/FONT]
[FONT="]rplc = "PLEASE BE VALUE IN CELL"[/FONT]
[FONT="]For Each sht In ActiveWorkbook.Worksheets[/FONT]
[FONT="]sht.Cells.Replace what:=fnd, Replacement:=rplc, _[/FONT]
[FONT="]LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _[/FONT]
[FONT="]SearchFormat:=False, ReplaceFormat:=False[/FONT]
[FONT="]Next sht[/FONT]
[FONT="]End Sub[/FONT]
[FONT="]I have a workbook with 60+ worksheets, and inconsistent data ranges within each. I need to create VBA code to:[/FONT]
- Search all worksheets in the workbook for specific text within a formula: Find = "*CODE"*
- Replace any formula containing *CODE* with the value in the cell that the formula is calculating.
[FONT="]Sub FindReplaceAll()[/FONT]
[FONT="]Dim sht As Worksheet[/FONT]
[FONT="]Dim fnd As Variant[/FONT]
[FONT="]Dim rplc As Variant[/FONT]
[FONT="]fnd = "*CODE*"[/FONT]
[FONT="]'I'd like to replace any cell containing containing *CODE* in the formula, with the value that the formula is calculating[/FONT]
[FONT="]rplc = "PLEASE BE VALUE IN CELL"[/FONT]
[FONT="]For Each sht In ActiveWorkbook.Worksheets[/FONT]
[FONT="]sht.Cells.Replace what:=fnd, Replacement:=rplc, _[/FONT]
[FONT="]LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, _[/FONT]
[FONT="]SearchFormat:=False, ReplaceFormat:=False[/FONT]
[FONT="]Next sht[/FONT]
[FONT="]End Sub[/FONT]