Instead of writing an If statement for every row, isn't there a better way of coding this:
Code:
Sub Main()
Dim Sys As Object,Sess As Object,xl as Object,wb as Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Set xl = CreateObject("Excel.Application")
Set wb = xl.Workbooks.Open("c:\_excel ccmbalance.xlsx")
Do
EndCheck = Sess.Screen.WaitForString("USSMSG10")
If Not EndCheck then
Sess.Screen.SendKeys "<Pf8>"
End If
Loop Until EndCheck
AmtCheck = trim(Sess.Screen.GetString( 1, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtVaule = trim(Sess.Screen.GetString( 1, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
AmtCheck = trim(Sess.Screen.GetString( 2, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtValue = trim(Sess.Screen.GetString( 2, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
AmtCheck = trim(Sess.Screen.GetString( 3, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtValue = trim(Sess.Screen.GetString( 3, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
AmtCheck = trim(Sess.Screen.GetString( 4, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtValue = trim(Sess.Screen.GetString( 4, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
AmtCheck = trim(Sess.Screen.GetString( 5, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtValue = trim(Sess.Screen.GetString( 5, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
AmtCheck = trim(Sess.Screen.GetString( 6, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtValue = trim(Sess.Screen.GetString( 6, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
AmtCheck = trim(Sess.Screen.GetString( 7, 10, 22))
If AmtCheck = "A VM001 - VM/SP" then
AmtValue = trim(Sess.Screen.GetString( 7, 10, 50))
wb.WorkSheets("Sheet1").Cells(11, "H").Value = AmtValue
End If
wb.SaveAs filename:= "c:\" & Format(Date, "mm.dd.yy") & "_excel ccmbalance.xlsx"
xl.Quit
End Sub