Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send data from Attachmate Extra to current selected cell in Excel

Status
Not open for further replies.

jay3120

Technical User
Dec 17, 2014
11
US
Hello,

I am running a macro in Attachmate Extra that has a small part where it needs to send 3 pieces of data to an Excel spreadsheet. I have successfully created code to send the data to the already open Excel file. The problem I am running into is that I need to send the info to the currently selected cell in column A, and cells in column B and C of the same row. If I can achieve this, I would also like to move the selected cell down 1 row as the last step.

Here is the code I have so far:
Code:
' Send info to Excel 
        Dim xlApp As Object, xlSheet As Object
        Set xlApp = Getobject("C:\Users\jay3120\Desktop\Excel Test.xlsx")
        Set xlSheet = xlApp.activesheet
         
        StartLine = Sess0.Screen.GetString (4,19,9)
        Middle = Sess0.Screen.GetString (4,31,2)
        FinishLine = Sess0.Screen.GetString (6,13,24)
         
        xlSheet.Cells(5303, "A").Value = StartLine
        xlSheet.Cells(5303, "B").Value = Middle
        xlSheet.Cells(5303, "C").Value = FinishLine
So instead of row 5303, I want it to be the row wherever the currently selected cell is.
I am using Attachmate Extra VB

Thank you for any help.
 
I'd avoid loops when other more direct methods are available.

Code:
With xlSheet.Cells(1,1).CurrentRegion
   NextRow = .Row + .Rows.Count
End With

With xlSheet.Cells(NextRow,1)
'Put your .offset for you 3 variables here
End With
 
here's a formula that you can use to return the last row:
=MAX(IF(ISBLANK(A1:A9001),"",ROW(A1:A9001)))

enter as an ARRAY (Control + Shift) in a blank cell that you do not use.


 
That was it! It works perfect. You're the man Skip. Thanks for the help, I couldn't have done it myself.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top