## Recommended Posts

My mind is pretty numb today so maybe I'm just not thinking of a different solution to this problem:

My script is reading cells in a spreadsheet and assigning the data to variables. I now want to enter this data into a form (using the variables), but since I have a large number of variables I'd rather not detail each send function. I'd rather use For...To..Next to put all similar sets of data into loops. So the below is an example of what I've got so far.

A1 = FirstName assigned to \$A1

A2 = LastName assigned to \$A2

A3 = Age assigned to \$A3

The long, hard way to enter this data looks like this now:

`send(""\$A1&"{TAB}"&\$A2&"{TAB}"&\$A3&"")`

I haven't been able to concatenate variables and I haven't found any examples of this. Could I make something that will Step a value in my variable so it runs A1, then A2, etc?

```for \$n = 1 to 3
send (" "&\$A"&\$n&"&"{TAB}
next```

The effect in my example would be that FirstName is entered into the first field in the form, then LastName in the next field, and finally Age.

##### Share on other sites

Dim \$a

for \$n=0 to 2

send (" "& \$A[\$n] & "&"{TAB})

next

##### Share on other sites

I'd use junkew's approach, but you can also use the Execute() function if you'd prefer not to use an array like junkew's example. It is easier.

Spoiler

Misc Code Snippets:
Projects: SubnetCalc
Cool Stuff:

##### Share on other sites

```#include <Misc.au3>

Dim \$a = ["Bob","Jones","25"]

For \$x = 0 to 2
Send(\$a[\$x] & _Iif(\$x < 2,"{TAB}",""))
Next```

##### Share on other sites

```#include <Misc.au3>

Dim \$a = ["Bob","Jones","25"]

For \$x = 0 to 2
Send(\$a[\$x] & _Iif(\$x < 2,"{TAB}",""))
Next```

Nice

Spoiler

Misc Code Snippets:
Projects: SubnetCalc
Cool Stuff:

##### Share on other sites

I would consider a 2 dimension Array for a spreadsheet as it would suit. Have a look at this Wiki page here for a good explaination of Array usage. You may also search the Example Scripts forum for a ExelCom based UDF if you are using M\$ Exel. Edited by MHz

##### Share on other sites

OK this has been a lot of help so far, but I'm not there yet. I've spent a lot of time studying the usage and relationship of variables and arrays and I have some more questions.

What covaks has in post 4 is great for me. What I'm thinking is:

1) My script reads the spreadsheet. Let's assume it's 4x3 Columns x Rows, labeled A1...3, B1...3, etc

2) The script assigns each cell A1 through D3 to a variable \$A1 through \$D3.

3) Now I want to use these variables in an array (\$arr), which I understand would be defined as

`dim \$arr = [[\$A1,\$A2,\$A3],[\$B1,\$B2,\$B3],[\$C1,\$C2,\$C3],[\$D1,\$D2,\$D3]]`

(is that right?)

Assuming that's right, is there an easy way to mass-define an array full of variables like this? Suppose I have \$arr. I don't want to define 1000 variables by hand! Can I use a For statement to define a huge array full of variables?

##### Share on other sites

OK this has been a lot of help so far, but I'm not there yet. I've spent a lot of time studying the usage and relationship of variables and arrays and I have some more questions.

What covaks has in post 4 is great for me. What I'm thinking is:

1) My script reads the spreadsheet. Let's assume it's 4x3 Columns x Rows, labeled A1...3, B1...3, etc

2) The script assigns each cell A1 through D3 to a variable \$A1 through \$D3.

3) Now I want to use these variables in an array (\$arr), which I understand would be defined as

`dim \$arr = [[\$A1,\$A2,\$A3],[\$B1,\$B2,\$B3],[\$C1,\$C2,\$C3],[\$D1,\$D2,\$D3]]`

(is that right?)

Assuming that's right, is there an easy way to mass-define an array full of variables like this? Suppose I have \$arr. I don't want to define 1000 variables by hand! Can I use a For statement to define a huge array full of variables?

What you need is

Specificly, the function

_ExcelReadArray() which is used to load parts of a spreadsheet into an array Edited by everseeker

Everseeker

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...