End of Macro

JTL9161

Well-known Member
Joined
Aug 29, 2012
Messages
593
Office Version
  1. 365
Platform
  1. Windows
I am using a macro from a co-worker that is no longer with the company.

Its a macro I attach to our main frame emulator. When I start it with a spreadsheet open it takes a code number from cell B2 on the spreadsheet, pastes it in the emulator, hits enter and then screen scrapes 6 pieces of data back to columns c through I on the spreadsheet. Then moves down 1 line to cell B3 and continues until there is a blank cell.

While I pretty much can figure out what each line of code in the macro does, I am trying to find the spot in the macro to add some additional steps after it reaches the blank line and stops with the screen scrapes and its back on spreadsheet. I want to add an option to format a column with the proper date format and then copy to another spreadsheet I already have open.

I keep trying to find the spot where the macro is done scraping but even when I put my additional code prior to the END SUB it reads it to early. Can someone tell me what spot within the below macro I can add my additional steps without making any (major) changes to the existing macro. I did not include each session command in the macro below but it needed I can add them at someone's request.


Thanks,
James

Sub NORX()
Dim lRow As Long, lLastRow As Long
Dim oMyWorkBook As Object
Dim oMyWorkSheet As Object

On Error Resume Next
Set oMyWorkBook = GetObject("C:\Users\jleonar3\Documents\DisCompare\MMDDYY-SGCS.XLSM")
Set oMyWorkSheet = oMyWorkBook.Sheets("sheet1")
On Error GoTo 0


If oMyWorkSheet Is Nothing Then
MsgBox "Source workbook not found."
Exit Sub
End If

With oMyWorkSheet
.Activate

'--find last row of data in col B. xlUp = -4162
lLastRow = .Cells(.Rows.Count, "B").End(-4162).Row

'--step through each row
For lRow = 2 To lLastRow
'--paste policy number onto clipboard
.Cells(lRow, "B").Copy

'--call procedure that will lookup corresponding network number
' and paste it to clipboard
Call DoBPLTerminalSession

'--paste network number into columm C
.Cells(lRow, "C").Select
.Paste

Call DoSTARTTerminalSession
.Cells(lRow, "D").Select
.Paste

Call DoENDTerminalSession
.Cells(lRow, "E").Select
.Paste

Call DoPLANTerminalSession
.Cells(lRow, "F").Select
.Paste

Call DoTRANSDATETerminalSession
.Cells(lRow, "G").Select
.Paste

Call DoSTATETerminalSession
.Cells(lRow, "I").Select
.Paste

Next lRow


End With
End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Put what you need after the End With and before the End Sub
 
Upvote 0

Forum statistics

Threads
1,224,821
Messages
6,181,163
Members
453,021
Latest member
Justyna P

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