Read last line of excel Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Read last line of excel

25 Sep 2021, 23:44

Hello !

I searched a lot, but I couldn't find it

How to read the last row from an excel sheet and show it in a gui ?
I will try it with a msgbox first

I tried using file read, that didn't work
This is the code that enters data into the sheet

Code: Select all

xl := ComObjCreate("excel.application")
wrkbk := xl.workbooks.open("C:\Users\user\Desktop\Name.xlsx")
xL.Sheets("Sheet Name").Activate
wrkbk1.Sheets("Sheet Name").Select

lstrw := xl.Range("B" xl.Rows.Count).End(-4162).Row
mnth := strsplit(xl.Range("C" lstrw).value, "-").2
nwrw := lstrw +1
nmbr := xl.Range("B" lstrw).value

if nmbr is not number
	nmbr := 0
if (mnth != A_MMM) {
	nmbr := 0
	nwrw++
}
;ENTRIES 

xl.Range("A" nwrw).value := nick
xl.Range("B" nwrw).value := runs
xl.Range("B" nwrw).NumberFormat := "## "
xl.Range("C" nwrw).value := A_DD "-" A_MM "-" A_YYYY
xl.Range("D" nwrw).NumberFormat := "[$-en-US]h:mm Am/Pm;@"
xl.range("D" nwrw).value := A_Hour ":" A_Min ":" A_Sec

wrkbk.close(1)
xl.quit()
I will be very grateful if someone can kindly guide me :)

Thank you

Regards.
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Read last line of excel

26 Sep 2021, 22:55

I apologise for posting this question in an irresponsible manner.

Turns out I myself have asked this question previously. In fact that was my very first post. (viewtopic.php?f=76&t=92041&p=407181&hilit=excel+message+box#p407181)

I have managed to build up on that and did this :

Code: Select all

xl := ComObjCreate("excel.application")
wrkbk := xl.workbooks.open("C:\Users\user\Desktop\Name.xlsm")

XL.Sheets("Sheet1").Activate
wrkbk1.Sheets("Sheet1").Select

lstrw := xl.Range("B" xl.Rows.Count).End(-4162).Row


MsgBox, % xl.Range("B" lstrw).Value


There are numbers in column B. like

2
4
5
1
7
5
4

e.t.c


When I run that script a message box is displaying the numbers in decimals

i.e 4.000000 e.t.c

How to make it show just 4?
Attachments
Screenshot 2021-09-27 092428.png
Screenshot 2021-09-27 092428.png (1.54 KiB) Viewed 472 times
Screenshot 2021-09-27 092338.png
Screenshot 2021-09-27 092338.png (2.51 KiB) Viewed 472 times
User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Read last line of excel  Topic is solved

26 Sep 2021, 23:09

Code: Select all

MsgBox, % xl.Range("B" lstrw).text
14.3 & 1.3.7
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Read last line of excel

26 Sep 2021, 23:12

Thank you flyingDman :)

It's working

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: wpulford and 423 guests