Getting my macro to work down a list in Excel correctly

johnvon

New Member
Joined
Feb 13, 2014
Messages
4
Hello everyone, I've lurked this forum for a few pieces of help here and there but just joined when I became really stumped. I'm trying to get my macro to pull information from my spreadsheet (each row one "location" address) and paste it into the program I'm working with. I used it to enter one at a time but now I'd like to have it do many as my volume as increased. What I have so far just enters the same row into the program repeatily - when I need to to enter once, then just down a row when done to enter the next.

Sorry, I'm a bit new to all of this but I'm slowly getting the hang of certain things little by little.

Here's my code I'm working on currently - thanks in advance to any pointers or tips, you have all already been very helpful on a couple other macro's I've done.

Sub Main()
Set Session = GetObject(, "xxx")
Application.ScreenUpdating = True
Dim lineX As Integer
With Session
Do Until ActiveCell.Value = ""
.TransmitANSI "1"
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMEnterKey


Range("A2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
Range("B2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Range("C2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
Range("D2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Range("E2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Range("F2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Range("G2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
Range("H2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
Range("I2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Range("J2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Range("K2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMTabKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

.TransmitANSI "Y"
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMEnterKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

.SetMousePos 14, 72
.TerminalMouse rcLeftClick, rcMouseRow, rcMouseCol
Range("M2").Select
.TransmitANSI ActiveCell.Value
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMEnterKey
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1


ActiveCell.Offset(1, 0).Select

.TransmitTerminalKey rcIBMF12Key
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.TransmitTerminalKey rcIBMF12Key
.WaitForEvent rcKbdEnabled, "30", "0", 1, 1

Loop




End With
Application.ScreenUpdating = True
Set Session = Nothing
End Sub
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Anyone with ideas? I just need it to go from row 2 to row 3 after the information in row 2 has been placed into the fields in the program I'm using. Then loop and continue going down a row after the information is pulled from the spreadsheet.

Any advice or additional information needed to help understand my goal?

Thanks,
John
 
Upvote 0
The activecell.offset and loop code towards the bottom can be ignored - it was an unsuccessful guess at getting this to work.
 
Upvote 0

Forum statistics

Threads
1,216,068
Messages
6,128,592
Members
449,460
Latest member
jgharbawi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top