Reputation: 304
I have an Input Box:
Sub Insert()
Dim myValue As Variant
myValue = InputBox("Need Input")
Range("A1").Value = myValue
End Sub
Now I want to use the value in A1 and insert this into another vba code called Sub pr()
. It is in the same worksheet and table.
It should replace "www.google.com"
for the input in A1.
Set Explorer = CreateObject("InternetExplorer.Application")
Explorer.Navigate "www.google.com"
When I use Sub Insert()
again, it should replace it again.
How can I use my value from A1 and write it into vba code?
Upvotes: 0
Views: 283
Reputation: 71
By supposing that the the url you want is in the range("A1") from the first sheet :
Sub pr()
Set Explorer = CreateObject("InternetExplorer.Application")
Dim url As String
url = ThisWorkbook.Sheets("Feuil1").Range("A1").Value
Explorer.Navigate url
End Sub
If this is the same sheet you can also use :
Sub pr()
Set Explorer = CreateObject("InternetExplorer.Application")
Dim url As String
url = ThisWorkbook.ActiveSheet.Range("A1").Value
Explorer.Navigate url
End Sub
Upvotes: 2