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