P
parahumanoid
Hi.
My apologies for the cross-post, original was mistakenly placed into
an italian-speaking group (I thought "it" stood for IT, turned out to
be a locale name).
Can someone post a VBA snippet for Excel 2007 that replaces the
requested substring in formulas with the provided string value. The
point is that if on a sheet I have a great number of cells where the
formula says"=july!whatever", referring to a sheet in another
workbook, and I make a copy of it for august, I don't want to hand-
edit these formulas. I want to run a macro that will request what to
replace (in this case "july") with what ("august"), so that the result
is "=august!whatever". I attempted the following:
==============================================
Sub ChangeFormulas()
Dim str1 As String
Dim str2 As String
Dim cur As Range
Dim result As Boolean
str1 = InputBox("Enter original string")
str2 = InputBox("Enter replacement string")
Application.ScreenUpdating = False
For Each cur In
ThisBook.ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
result = cur.Replace(str1, str2)
If result = False Then
MsgBox ("Not changed")
End If
Next
End Sub
====================================================
The message box never fires, but the replacement doesn't occur, all
formulas stay intact. What am I doing wrong?
My apologies for the cross-post, original was mistakenly placed into
an italian-speaking group (I thought "it" stood for IT, turned out to
be a locale name).
Can someone post a VBA snippet for Excel 2007 that replaces the
requested substring in formulas with the provided string value. The
point is that if on a sheet I have a great number of cells where the
formula says"=july!whatever", referring to a sheet in another
workbook, and I make a copy of it for august, I don't want to hand-
edit these formulas. I want to run a macro that will request what to
replace (in this case "july") with what ("august"), so that the result
is "=august!whatever". I attempted the following:
==============================================
Sub ChangeFormulas()
Dim str1 As String
Dim str2 As String
Dim cur As Range
Dim result As Boolean
str1 = InputBox("Enter original string")
str2 = InputBox("Enter replacement string")
Application.ScreenUpdating = False
For Each cur In
ThisBook.ActiveSheet.UsedRange.SpecialCells(xlCellTypeFormulas)
result = cur.Replace(str1, str2)
If result = False Then
MsgBox ("Not changed")
End If
Next
End Sub
====================================================
The message box never fires, but the replacement doesn't occur, all
formulas stay intact. What am I doing wrong?