Hi guys,
So I have this macro to multiply all any row in a workbook that has an X in column B by a coefficient I designate. The macro works but when I run it not only does it multiply the rows i want but it also makes all the vlookups and formulas in any other cell that does not have a X in column B disappear and just leaves the most recent number that was in the cell but no formulas or vlookup. How do I stop this from happening I am very confused. Here is the code.
Thank you everyone,
Your friend
Sub test123()
Dim ws As Worksheet, e, coef, myCurr As String
For Each e In Array(Array("Euro", "a1"), Array("US Dollar", "b1"))
If Sheets("Config & Summary").[i2] Like "*" & e(0) & "*" Then
myCurr = e(0)
coef = Sheets("currency").Range(e(1))
Exit For
End If
Next
For Each e In Array(Array("British Pound", "a2"), Array("US Dollar", "b2"))
If Sheets("Config & Summary").[i2] Like "*" & e(0) & "*" Then
myCurr = e(0)
coef = Sheets("currency").Range(e(1))
Exit For
End If
Next
If myCurr = "" Then MsgBox "No matched data in ""Config!I2""": Exit Sub
For Each ws In Worksheets
With ws.Range("b3", ws.Range("b" & Rows.Count).End(xlUp)).Resize(, 4)
If Application.CountIf(.Columns(1), "x") Then
With .Offset(, 1)
.Value = ws.Evaluate("if(b3:b" & .Cells(.Rows.Count, 1).Row & _
"=""x""," & .Address & "*" & coef & "," & .Address & ")")
End With
End If
End With
ws.[h2] = myCurr
Next
End Sub
Bookmarks