cactusman
New Member
- Joined
- Oct 15, 2012
- Messages
- 20
Morning, all!
I have the below macro that returns data from my AS400...the problem is it goes back to 2011....I need to create a method of asking the user what months and years they want data from. I thought the little calendar-type control:
would be a nice touch, but not a requirement.
The macro:
Any assistance anyone can provide is greatly appreciated!
Thanks in advance!
Matt
I have the below macro that returns data from my AS400...the problem is it goes back to 2011....I need to create a method of asking the user what months and years they want data from. I thought the little calendar-type control:
would be a nice touch, but not a requirement.
The macro:
Code:
Sub GetData()
'
' GetData Macro
' Gets Sheet 1 data from Infor
'
'
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:="ODBC;DSN=INFOR;", _
Destination:=Range("$A$5")).QueryTable
.CommandText = Array( _
"SELECT MOROUT.ORDNO, MOROUT.RLHTD, MOROUT.SRLHU, MOMASTLB.MOSTMY, MOMASTLB.OCDTMY" & Chr(13) & "" & Chr(10) & "FROM S10A7F0P.AMFLIB.MOMASTLB MOMASTLB, S10A7F0P.AMFLIB.MOROUT MOROUT" & Chr(13) & "" & Chr(10) & "WHERE MOROUT.ORDNO = MOMASTLB.ORDRMY AND ((MOMASTLB.MOSTMY='" _
, "55'))")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Table_Query_from_INFOR"
.Refresh BackgroundQuery:=False
End With
Range("E5").Select
ActiveCell.FormulaR1C1 = "Variance"
Range("E6").Select
ActiveCell.FormulaR1C1 = "=[@RLHTD]/[@SRLHU]"
Range("E7").Select
ActiveWindow.SmallScroll Down:=-30
Range("F5").Select
ActiveCell.FormulaR1C1 = "Completed Date"
Range("F6").Select
ActiveCell.FormulaR1C1 = _
"=DATE(LEFT(RC[-1],3),MID(RC[-1],4,2),RIGHT(RC[-1],2))"
Range("F7").Select
Columns("F:F").ColumnWidth = 20.14
Range("H7").Select
End Sub
Any assistance anyone can provide is greatly appreciated!
Thanks in advance!
Matt