AHK - EXCEL

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

AHK - EXCEL

Post by Fulminare » 02 Aug 2021, 04:15

This is a continuation of my previous post
(https://www.autohotkey.com/boards/viewtopic.php?p=413158#p413158)

with the following code ,
Month specific serial number,
Date,
"static text"
and Time are getting entered into -
column A,B,C,D, respectively.
once the month changes a gap of one row is being maintained.

Code: Select all

xl := ComObjCreate("excel.application")
wrkbk := xl.workbooks.open("C:\Users\Administrater\Desktop\Lol.xlsx")
lstrw := xl.Range("A" xl.Rows.Count).End(-4162).Row
mnth := strsplit(xl.Range("B" lstrw).value, "-").1
nwrw := lstrw + 1

nmbr := xl.Range("A" lstrw).value

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



colctxt := "static text"
xl.Range("A" nwrw):= nmbr + 1
xl.Range("A" nwrw).NumberFormat := "## "
xl.Range("B" nwrw).value := A_MM "/" A_DD "/" A_YYYY
xl.Range("C" nwrw).value := colctxt
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()

Now I made another script.

Code: Select all

lastMonth := lastMonth("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Spt", "Oct", "Nov", "Dec")

MsgBox = %lastMonth% 
lastMonth(list*)	;this way you can decide how the element should count back.i.e a string like Feb, or 02...
{
Index := A_Mon -1
lastMon .= list[Index] 
Return, %lastMon% 
; Return, list[Index]	;to only return the month
}

xl := ComObjCreate("excel.application")
wrkbk := xl.workbooks.open("C:\Users\Administrater\Desktop\Lol.xlsx")
lstrw := xl.Range("A" xl.Rows.Count).End(-4162).Row
mnth := strsplit(xl.Range("B" lstrw).value, "-").1

nwrw := lstrw + 1
nmbr := xl.Range("A" lstrw).value


if nmbr is not number
	nmbr := 0

if (mnth != A_MM) {
	nmbr := 0
	nwrw++
}

coletxt := MsgBox  "Bill Paid"
xl.Range("B" nwrw).value := A_MM "/" A_DD "/" A_YYYY
xl.Range("E" nwrw).value := coletxt

wrkbk.close(1)
xl.quit()
The purpose of this 2nd script is, when I run it, the following must get entered

Date - in column B

"name of the previous month" Bill paid"- in column E.


Conditions :

when I run the first script again , it's data should be entered in the line after the "bill paid" row

If the second script is run on the first day of a month , a gap of one row should be maintained from the previous month's entry.



Currently after running the second script and then running the first script , their lines are getting merged


Can someone please tell me what to do ?

P.s all the scripts that are used or created have been cut and pasted from other posts.
with trial and error I was able to modify scripts to my requirement.

while answering kindly note that I don't know any coding.

Thank you

Return to “Ask for Help (v1)”