I am trying to use a dynamic drop down table which adjusts the formulas in a sheets. (for example if the drop down value is abc, then part of the formulas will be adjusted via find and replaced) If I do it manually, it works out perfectly, but the code just selects my range and doesn't do anything else. I recorded my manual work with the Macro recorder and get the following result:
Sub a()
Range("B50:I60","B30:I40","B70:I90").Select
Selection.Replace What:=")", Replacement:=";Sheet1!X:X;"";9;"")", _ LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=Format, FOrmulaBersion:=xlReplaceFormula2
End Sub
I want it to look like this:
Sub replace()
If Range("A2").Value="Juli 2020" _
Then Range("B50:I60","B30:I40","B70:I90").Select
Selection.Replace What:=")", Replacement:=";Sheet1!X:X;"";9;"")", _ LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=Format, FOrmulaBersion:=xlReplaceFormula2
End If
End Sub
Both of these codes don't work when I run them from VBA, event though if I do it manually I can easily adjust my formulas. PS:I thought refering to the worksheet directly and activate it would help but it doesn't change anything. Can anyone help? It's very frustrating… Hugs, Annabelle