这是我下面的内容。当它通过下一个循环时,我需要循环将 RC = MyHost.keys(DestinationE) 更改为 I8 中的值到同一列 I10 中的两行。宏可以工作,但是当它循环时,它会从中提取相同的数据。我在这里做错了什么。请在我的头爆炸之前帮忙。非常感谢!
Sub PTPMLRs()
Dim MyHost As Object
Dim HE As Object
Set HE = CreateObject("HostExplorer")
Set MyHost = HE.CurrentHost
Dim RC As Integer
Dim Lsheet As Worksheet
Set Lsheet = ThisWorkbook.Worksheets("PTPMLRs")
Dim Station1 As String
Dim Station1Loc As Range
Dim Station2 As String
Dim Station2Loc As Range
Dim Station3 As String
Dim Station3Loc As Range
Dim DestinationE As String
Dim DestinationELoc As Range
Dim DestinationN As String
Dim DestinationNLoc As Range
Dim DestinationA As String
Dim DestinationALoc As Range
Dim Vehicle As String
Dim VehicleLoc As Range
Dim AllVeh As String
Dim AllVehLoc As Range
Dim BeginDate As String
Dim BeginDateLoc As Range
Dim EndDate As String
Dim EndDateLoc As Range
Dim BeginTime As String
Dim BeginTimeLoc As Range
Dim EndTime As String
Dim EndTimeLoc As Range
Dim Inv As String
Dim InvLoc As Range
Dim Mlr As String
Dim MlrLoc As Range
Set Station1Loc = Lsheet.Range("I6")
Set Station2Loc = Lsheet.Range("M6")
Set Station3Loc = Lsheet.Range("Q6")
Set DestinationELoc = Lsheet.Range("I8")
Set DestinationNLoc = Lsheet.Range("M8")
Set DestinationALoc = Lsheet.Range("Q8")
Set VehicleLoc = Lsheet.Range("E6")
Set AllVehLoc = Lsheet.Range("E8")
Set BeginDateLoc = Lsheet.Range("E10")
Set EndDateLoc = Lsheet.Range("E12")
Set BeginTimeLoc = Lsheet.Range("E14")
Set EndTimeLoc = Lsheet.Range("E16")
Set InvLoc = Lsheet.Range("E18")
Set MlrLoc = Lsheet.Range("E20")
Station1 = Station1Loc.Value
Station2 = Station2Loc.Value
Station3 = Station3Loc.Value
DestinationE = DestinationELoc.Value
DestinationN = DestinationNLoc.Value
DestinationA = DestinationALoc.Value
RC = MyHost.Runcmd("pF2")
RC = MyHost.keys(Station1)
RC = MyHost.Runcmd("pF3")
RC = MyHost.Runcmd("TAB")
RC = MyHost.Runcmd("TAB")
RC = MyHost.Runcmd("TAB")
Do Until DestinationELoc.Value = ""
Vehicle = VehicleLoc.Value
AllVeh = AllVehLoc.Value
BeginDate = BeginDateLoc.Value
EndDate = EndDateLoc.Value
BeginTime = BeginTimeLoc.Value
EndTime = EndTimeLoc.Value
Inv = InvLoc.Value
Mlr = MlrLoc.Value
RC = MyHost.Runcmd("pF2")
RC = MyHost.keys(DestinationE)
RC = MyHost.Runcmd("pF3")
RC = MyHost.Runcmd("PAGE-DOWN")
RC = MyHost.Runcmd("INSERT-HERE")
RC = MyHost.Runcmd("TAB")
RC = MyHost.Runcmd("TAB")
RC = MyHost.keys(Vehicle)
RC = MyHost.Runcmd("TAB")
RC = MyHost.keys(BeginDate)
RC = MyHost.Runcmd("TAB")
RC = MyHost.keys(EndDate)
RC = MyHost.Runcmd("PAGE-DOWN")
RC = MyHost.keys(BeginTime)
RC = MyHost.Runcmd("TAB")
RC = MyHost.keys(EndTime)
RC = MyHost.Runcmd("TAB")
RC = MyHost.keys(Inv)
RC = MyHost.Runcmd("TAB")
RC = MyHost.keys(Mlr)
RC = MyHost.Runcmd("pF4")
RC = MyHost.keys(AllVeh)
RC = MyHost.Runcmd("ENTER")
RC = MyHost.Runcmd("ENTER")
RC = MyHost.Runcmd("PAGE-UP")
RC = MyHost.Runcmd("PAGE-UP")
Set DestinationELoc = DestinationELoc.Offset(2, 0)
Loop
End Sub