hi,
with
Cell A1: "MyVar"
Cell A2: "Purple"
Cell A3: "String"
copy the following code in the Module1, and run macro ModifyCode
Sub test1()
End Sub
Sub ModifyCode()
Dim code(1)
Dim Mdl As String, MyMacro As String
Mdl = "Module1"
MyMacro = "test1"
code(0) = "Dim " & [A1] & " as " & [A3]
code(1) = "msgbox [A2]"
For i = 0 To 1
s = s & code(i) & Chr(10)
Next
With ThisWorkbook.VBProject.VBComponents(Mdl).codemodul e
..InsertLines .ProcStartLine(MyMacro, 0) + 1, s
End With
test1
With ThisWorkbook.VBProject.VBComponents("Module1").cod emodule
..DeleteLines .ProcStartLine("ModifyCode", 0), .ProcCountLines("ModifyCode", 0)
End With
End Sub
isabelle
Le 2016-07-18 Ã* 18:14,
a écrit :
Cell A1: "MyVar"
Cell A2: "Purple"
Cell A3: "String"
I want to run code that does the following
Public MyVar as String
MyVar = "Purple"
How would I do that?
it's kinda like
Execute "Dim " & range(A1) & " as " & range(A3)
Execute range(A1) & " = '" & range(A2) & "'"
Is there a way?