Excel Macro: Type mismatch (Error 13)
On 1/6/2018 at 12:25:03 PM Claus Busch wrote:
Hi,
Am Fri, 5 Jan 2018 14:13:57 +0000 (UTC) schrieb tb:
What I am looking for is a macro that parses each worksheet
separately and for each cell that is formatted as currency ($ - U.S.
Dollars) applies the "pctChange" value specified in that worksheet.
try:
Sub Test()
Dim wsh As Worksheet
Dim rngc As Range, c As Range
Dim factor As Double
Dim strFormat As String
strFormat = """$""#,##0.00_);(""$""#,##0.00)"
For Each wsh In Worksheets
With wsh
Set c = .UsedRange.Find("pctChange", LookIn:=xlValues)
If Not c Is Nothing Then factor = 1 + c.Offset(1, 0)
If c Is Nothing Or factor = 1 Then GoTo Skip
For Each rngc In .UsedRange
If rngc.NumberFormat = strFormat And IsNumeric(rngc) Then
rngc = Round(rngc * factor, 2)
End If
Next
End With
Skip:
Next
End Sub
Regards
Claus B.
Claus, I was not able to use your macro. Basically, nothing happes
when I launch it. Is there something else that I need to do in order
to successfully run your macro?
Garry's macro worked for me, but I am interested in learning more about
macros and maybe I'm doing something wrong with yours...
--
tb
|