Editing a macro with a macro

farmock

Board Regular
Joined
Sep 10, 2006
Messages
60
I have about 50 web sites I get info from daily. The address format is www.sampleaddress.com/symbol where the address is this for each site except symbol represents 3 or 4 letters for each specific site. I had been having a problem finding a method that would open the sites. I found Juan's method here which will open the sites. This is his method:

Sub Test()
Const url As String = "www.mrexcel.com/board2" ' ****** the address is obtained from another macro
Dim ie As Object
'Dim document As Object
Set ie = CreateObject("internetexplorer.application")
With ie
.Visible = True
.Navigate url
Do While .ReadyState <> 4
DoEvents
Loop
.ExecWB 17, 2
.ExecWB 12, 2
ActiveSheet.Paste Range("A1")
End With
End Sub

However, I am not able to use a variable with the address. He states that a macro should be used to enter the address. I have tried to find documentation on how to modify a macro with another macro to no avail. I do not understand how to do this. Can anybody help or send me in a direction where I can find out how to do this? Thanks for any help you can provide. Frank
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,351
Office Version
  1. 365
Platform
  1. Windows
Frank

I see no need to actually use code to alter code.

You should just be able to use simple string concatenation to construct the required URL.

For example.
Code:
Sub Test()
Dim ie As Object
Dim symbol As String
Dim url As String
    
    symbol = "board2" ' note this could be replaced with a range reference
    url = "www.mrexcel.com/" & symbol
    
    Set ie = CreateObject("internetexplorer.application")
    
    With ie
        .Visible = True
        .Navigate url
        Do While .ReadyState <> 4
            DoEvents
        Loop
        .ExecWB 17, 2
        .ExecWB 12, 2
        ActiveSheet.Paste Range("A1")
    End With

End Sub
 

farmock

Board Regular
Joined
Sep 10, 2006
Messages
60
Macro in Macro

Norie,
Thanks so much for the help! It works! I have been struggling with this for a couple of months. Thanks again. Frank
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,958
Messages
5,856,520
Members
431,820
Latest member
Tori Murphy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top