Forum

Code should input t...
 
Notifications
Clear all

Code should input text for each line but Does this only once..

3 Posts
2 Users
0 Reactions
102 Views
(@leslie-smith)
Posts: 9
Eminent Member
Topic starter
 

I have a Macro that reads times entered on an excel sheet and opens another application that inputs delay time(downtime). After the downtime has been entered, the macro should enter done on  each line after completing the loop.. Not sure why this is not happening

This is the code that should write to the excel sheet to say done. 

Cells(xlrow, 6) = DONE

Here is the entire code and I have attached the excel sheet as well. 

 

Sub DT_ACMAA()
'
' DT_ACMAA Macro
'

Dim bzhao As Object
Set bzhao = CreateObject("BZWhll.WhllObj")
bzhao.Connect ""

Dim myAsgn As Variant
Dim myRange As Excel.Range
Dim xlrow As Integer

DONE = "YES"

xlrow = 2

Set myRange = ActiveSheet.Range("B2:B52")

myAuth = Cells(xlrow, 5)
Delay_Code = Cells(xlrow, 3)
Delay_timeM = Cells(xlrow, 4)

 

For Each myAsgn In myRange
If myAsgn = "" Then
Exit For
End If

bzhao.sendkey "<PF3>"
bzhao.Wait 0.2
bzhao.sendkey "ACMAA"
bzhao.Wait 0.2
bzhao.sendkey "<enter>"
bzhao.Wait 0.2
bzhao.sendkey myAuth
bzhao.Wait 0.2
bzhao.sendkey "<TAB>"
bzhao.Wait 0.2
bzhao.sendkey "d"
bzhao.Wait 0.2
bzhao.sendkey "<tab>"
bzhao.Wait 0.2
bzhao.sendkey Delay_Code
bzhao.Wait 0.2
bzhao.sendkey myAsgn
bzhao.Wait 0.2
bzhao.sendkey "<tab>"
bzhao.Wait 0.2
bzhao.sendkey Delay_timeM
bzhao.Wait 0.2
bzhao.sendkey ":"
bzhao.Wait 0.2
bzhao.sendkey "0"
bzhao.Wait 0.2
bzhao.sendkey "0"
bzhao.Wait 0.2
bzhao.sendkey "<ENTER>"
bzhao.Wait 0.2
bzhao.sendkey "m"
bzhao.Wait 0.2
bzhao.sendkey "y"
bzhao.Wait 0.2
bzhao.sendkey "<ENTER>"
bzhao.Wait 0.2
bzhao.sendkey "e"
bzhao.Wait 0.2
bzhao.sendkey "e"
bzhao.Wait 0.2
Cells(xlrow, 6) = DONE

Next myAsgn

 

End Sub

 
Posted : 20/08/2020 11:18 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Leslie,

You start with xlrow=2, but inside the loop you are not increasing the row index, so it will always remain 2.

Before next MyAssgn, use xlrow=xlrow+1

 
Posted : 22/08/2020 2:10 am
(@leslie-smith)
Posts: 9
Eminent Member
Topic starter
 

Hi Catalin!!

 

Thank you so much!! I always seem to forget about incrementing from my starting point! 

 
Posted : 22/08/2020 10:53 am
Share: