Question about Array

Get help with using AutoHotkey and its commands and hotkeys
inseption86
Posts: 109
Joined: 19 Apr 2018, 00:24

Question about Array

15 Nov 2020, 06:42

Good afternoon. How to solve this problem?

Code: Select all

list := [all, public, opublic, vospit, PKV, pedag, level, data_diag, diag]

For k, v in list
{
v := book1.workSheets(A_index+1).Cells.(book1.workSheets(A_index+1).Rows.Count, "A").End(xlUp := -4162).Row - 1
book1.Worksheets(A_index+1).name := book1.Worksheets(A_index+1).name "_" v	
}

MsgBox % all  ????? 
MsgBox % public  ????? 
.....
User avatar
boiler
Posts: 6652
Joined: 21 Dec 2014, 02:44

Re: Question about Array

15 Nov 2020, 07:35

One issue is that you need quotes around the values in your array assignment.

What are you expecting to see with MsgBox, % all?

Also, it would be easier to type and shorter to use k instead of A_Index in your for loop, which you might as well do since you've defined it.
User avatar
Chunjee
Posts: 754
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Question about Array

15 Nov 2020, 12:38

What is the problem? I don't see an obvious one.

If all and public are variables. We can't see them in your example. Maybe you meant to do list := ["all", "public", "opublic", "vospit", "PKV", "pedag", "level", "data_diag", "diag"]
User avatar
boiler
Posts: 6652
Joined: 21 Dec 2014, 02:44

Re: Question about Array

15 Nov 2020, 12:54

Chunjee wrote:
15 Nov 2020, 12:38
Maybe you meant to do list := ["all", "public", "opublic", "vospit", "PKV", "pedag", "level", "data_diag", "diag"]
Hence this comment:
boiler wrote:
15 Nov 2020, 07:35
One issue is that you need quotes around the values in your array assignment.
inseption86
Posts: 109
Joined: 19 Apr 2018, 00:24

Re: Question about Array

16 Nov 2020, 04:33

so ?

Code: Select all


list := ["all", "public", "opublic", "vospit", "PKV", "pedag", "level", "data_diag", "diag"]

For k, v in list
{
v := book1.workSheets(A_index+1).Cells.(book1.workSheets(A_index+1).Rows.Count, "A").End(xlUp := -4162).Row - 1
book1.Worksheets(A_index+1).name := book1.Worksheets(A_index+1).name "_" v

list[k] := v
}
.......

book1.Worksheets(1).range("A6").value := list[2]  ;list.public
book1.Worksheets(1).range("B6").value := list[1] ; list.all
.....

User avatar
Chunjee
Posts: 754
Joined: 18 Apr 2014, 19:05
GitHub: Chunjee

Re: Question about Array

16 Nov 2020, 06:10

boiler wrote:
15 Nov 2020, 12:54
Hence this comment:
I saw your post. :thumbup:
User avatar
boiler
Posts: 6652
Joined: 21 Dec 2014, 02:44

Re: Question about Array

16 Nov 2020, 07:33

inseption86 wrote:
16 Nov 2020, 04:33
so ?
Is it doing what you want? If not, can you describe what it's supposed to do and what it's actually doing?
Last edited by boiler on 16 Nov 2020, 08:43, edited 1 time in total.
inseption86
Posts: 109
Joined: 19 Apr 2018, 00:24

Re: Question about Array

16 Nov 2020, 07:45

Code: Select all


book1.workSheets(1).cells(1,1)).AutoFilter(......)
book1.Worksheets(1).cells(lastrow,2)).copy
book1.Worksheets(2).Range("A1").Pastespecial()
book1.Worksheets(2).Range("A:A").RemoveDuplicates(1,2)
all := book1.workSheets(2).Cells.(book1.workSheets(2).Rows.Count, "A").End(xlUp := -4162).Row - 1
book1.Worksheets(2).name := book1.Worksheets(2).name "_" all
;..........................................................................................
book1.workSheets(1).cells(1,1)).AutoFilter(......)
book1.Worksheets(1).cells(lastrow,2)).copy
book1.Worksheets(3).Range("A1").Pastespecial()
book1.Worksheets(3).Range("A:A").RemoveDuplicates(1,2)
public := book1.workSheets(3).Cells.(book1.workSheets(3).Rows.Count, "A").End(xlUp := -4162).Row - 1
book1.Worksheets(3).name := book1.Worksheets(3).name "_" public
;..........................................................................................
book1.workSheets(1).cells(1,1)).AutoFilter(......)
book1.Worksheets(1).cells(lastrow,2)).copy
book1.Worksheets(4).Range("A1").Pastespecial()
book1.Worksheets(4).Range("A:A").RemoveDuplicates(1,2)
opublic := book1.workSheets(4).Cells.(book1.workSheets(4).Rows.Count, "A").End(xlUp := -4162).Row - 1
book1.Worksheets(4).name := book1.Worksheets(4).name "_" opublic
;..........................................................................................

book2.Worksheets(1).range("A1").value := all
book2.Worksheets(1).range("A2").value := public
book2.Worksheets(1).range("A3").value := opublic


User avatar
boiler
Posts: 6652
Joined: 21 Dec 2014, 02:44

Re: Question about Array

16 Nov 2020, 08:50

I wish you could just describe in words what you are trying to accomplish. Are you trying to create properties named name_public and name_all? Are they properties that already exist? The syntax of what you are trying to do would not be correct even without knowing what it is you're trying to accomplish.

Return to “Ask For Help”

Who is online

Users browsing this forum: AHKStudent, Google [Bot], JackbobEvolved, martin536, mikeyww and 49 guests