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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,006
Messages
6,122,665
Members
449,091
Latest member
peppernaut

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
Back
Top