Select Cell based on loop?

jtsains

Board Regular
Joined
Apr 29, 2011
Messages
103
I have some code I need to update. Here is the concept behind the code:

The macro starts will cell A2 and copies a customer number which finds the record in my database.

It then selects a specific position in the database to update the records to a what is equal to cell H1 in the spreadsheet. (done via copy and paste.)

What i want to do instead is to have excel copy the cell in row G that coorisponds with the customer number in column A.

A2 = 12345 *(customer Number)
G2 = $19/85 *(Price quoted to customer)

I will be updating thousands of records at the same time so this is looped to update all records based on the contents in column G of each customer number.

Please let me know if you have any suggestions. I don't want to drastically change the current code because it works well.

The portion in RED is the one that would be replaced to select the cell in row G that i would need to update.

Rich (BB code):
Sub WPGM()
Dim i As Integer
Call ConnectWRQ
Session.TransmitANSI "WPGM"
Session.TransmitTerminalKey rcIBMEnterKey
Pause
 
For i = 2 To Range("A" & Rows.Count).End(xlUp).Row
Range("A" & i).Select
 
Selection.Copy
Session.TransmitANSI "3"
Paste
Pause
Session.TransmitTerminalKey rcIBMEnterKey
Pause
 
If Session.GetDisplayText(24, 2, 22) = "INVALID ACCOUNT NUMBER" Then
MsgBox "Account Number Invalid", vbCritical
Application.CutCopyMode = False
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Session.TransmitTerminalKey rcIBMClearKey
End If
 
Range("H1").Select
Selection.Copy
CurPos 19, 22
Pause
Paste
Session.TransmitTerminalKey rcIBMEraseEOFKey
Pause
Session.TransmitTerminalKey rcIBMEnterKey
Pause
Session.TransmitTerminalKey rcIBMPf2Key
Pause
Session.TransmitTerminalKey rcIBMPf3Key
 
Next i
Session.Exit
 
Last edited:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Looks like 45 people have read my post, but no one has responded. :(
If anyone can help, I would really appreciate it.
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,795
Members
452,943
Latest member
Newbie4296

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