Web Query & combining macros,

Sprucy

Board Regular
Joined
Oct 31, 2005
Messages
92
Hey Eeryone,

Many thanks to everyone, I try to read as many Q&A's as I can and man, I owe you all alot.

Need some help, I need 3 macros to be "linked", meaning, run macro A,B & C in order. Do I rewrite them or add in a command to tell VBA to run the next macro?

A) Will launch IE, input a date in a field, the will generate data
B) Does a Copy/Paste from IE to XLS
C) Trims the data (removes spaces)
... I'd like to add more macros but lets get these working first.

Now, they all work fine on there own but I need macro B to run based on the data generated by Macro A (preferably the specific data, which is the bottom half of the webpage) as it is, it copies the whole page, in which case I would need to add a macro to say: Copy/Paste A5:F1000 from Sheet3 to A9:F1004 on Sheet1, then Delete Sheet3...
NOTE: Macro A & B are based on an Intranet site, sorry about that....

Trying to kep it short, so feel free to ask for more info..

Sub dcc()
'Open site if it requires a PassWord Model or field input validation!
Dim IE As Object

Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True

'Go to this Web Page!
IE.Navigate "http://myintranetsite.com"
'Check for good connection to web page loop!
Do
If IE.ReadyState = 4 Then
IE.Visible = False
Exit Do
Else
DoEvents
End If
Loop

'Wait for window to open!
Application.Wait (Now + TimeValue("0:00:01"))
'MsgBox "Done"
IE.Visible = True

'Send date based on Cell A1!
SendKeys "{TAB}", True
SendKeys "{TAB}", True
'May need additional SendKeys as needed?
'Determine by the actual key-stroks needed!
SendKeys [a1].Value, True
SendKeys "{TAB}", True
SendKeys "{ENTER}", True
Application.Wait (Now + TimeValue("0:00:10"))
IE.Quit

End Sub


-----------------

Sub pasteWeb()
Const url As String = "http://my intranet or see macro A"
' ****** 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
Sheet2.Paste Range("a1")
End With

End Sub

---------------------------

Sub TrimRange()
'
' TrimRange Macro
' Macro recorded 11/15/2005 by
'
Dim WorkRange As Range

Set WorkRange = Range("D8:D" & Range("D65536").End(xlUp).Row)

For Each Cell In WorkRange
If Cell.Value = "" Then
GoTo Next1
ElseIf IsNumeric(Cell.Value) Then
Cell.Value = Cell.Value * 1
Else
Cell.Value = Trim(Cell.Value)
End If
Next1:
Next Cell

End Sub
-------------------------------------


Thanks in advance,
Cheers,
Sprucy
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Very simply, you could use the CALL feature to run the 2nd and third macros from your first one....

add before "End Sub" in your first macro:

Call pasteWeb
Call TrimRange

Hope this helps,
Andywiz
 
Upvote 0
Andywiz,

Thanks for the CALL command, 1 part solved.
But I do I tell the 2nd macro to Copy & paste the webpage data from the 1st macro?
The way it is written now, the pasteWeb macro opens a new webpage...

Any ideas?
 
Upvote 0

Forum statistics

Threads
1,203,686
Messages
6,056,738
Members
444,888
Latest member
Babi_mn

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