I need to update (X,Y) coordinates in a program called BlueZone using VBA based on a 6 digit location ID.
The three variables (1) location (2) X (3) Y are all on an spreadsheet.
I want my code to loop through each location ID (column A) and get the corresponding X and Y coordinates (columns B, C respectively). IOW, my cell A2 = location ID, B2 = X coordinate, C3 = Y coordinate.
Sub FiXY()
'bzhao is the object declaration to manipulate emulation software by BlueZone
Dim bzhao As Object
Set bzhao = CreateObject("BZWhll.WhllObj")
bzhao.Connect ""
Dim myLoc As Variant
myRange = ActiveSheet.Range("A2:C1000") 'have also tried "A2:A1000"
For Each myLoc In myRange
'end loop at blank cell
If myLoc = "" Then
Exit For
End If
'Query location
bzhao.SendKey "Q"
bzhao.Wait 0.2
bzhao.SendKey myLoc 'passes just fine
bzhao.Wait 0.2
bzhao.SendKey "<enter>"
bzhao.Wait 0.2
'does not work
bzhao.SendKey myLoc.Offset(0,1).Value
bzhao.SendKey myLoc.Offset(0,2).Value
'does not work
bzhao.SendKey myRange.Offset(0,1).Value
bzhao.SendKey myRange.Offset(0,2).Value
Next myLoc
End Sub
I understand that SendKey is not ideal, but this loop has worked flawlessly for me with a static X or Y that I can call from a cell on the sheet, so I believe it the structure of my code is the issue.
How do I get the three variables into my loop?