Jump to content

Concatenate variables?


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.

Data from the spreadsheet:

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.

Link to comment
Share on other sites

Link to comment
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
Link to comment
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[4][3]), which I understand would be defined as

dim $arr[4][3] = [[$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[200][5]. I don't want to define 1000 variables by hand! Can I use a For statement to define a huge array full of variables?

Link to comment
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[4][3]), which I understand would be defined as

dim $arr[4][3] = [[$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[200][5]. 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

http://www.autoitscript.com/forum/index.ph...hl=ExcelCOM_UDF

Specificly, the function

_ExcelReadArray() which is used to load parts of a spreadsheet into an array :)

Edited by everseeker

Everseeker

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...