View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
AB[_2_] AB[_2_] is offline
external usenet poster
 
Posts: 236
Default Get the content of each value of a line

Not considering all the specifics and making it dynamic, would
something like this do the trick (i mean in general - would structure
like this ('type') be something you're after):

Public Type Structure
Code As String
Firm As String
Address1 As String
City As String
End Type


Sub FillMyStructure()
Dim mStrc As Structure

With mStrc
.Code = Cells(2, 1)
.Firm = Cells(2, 2)
.Address1 = Cells(2, 3)
.City = Cells(2, 4)
End With

End Sub

Paste the above code in a new standard VBA module and try it out. Try
stepping it throughy with F8. You can also try reading some help un
using UDT (User Defined Type) whereby a bunch of variables are
combined into one type - as per above there is a type 'Structure' that
holds 'Code', 'Address1', 'Firm', 'City'.

A.


On Jul 15, 2:45*pm, Nemroth wrote:
Thanks for your answer
Sorry if I wasn't explicit, I'm not english/american native language.
By 'table of variables' I mean a dynamic array and by 'Structure' I mean
a collection like :

* * *Dim Code As String
* * *Dim Firm As String
* * *Dim Adress1 As String
* * *Dim City As String

and then someting like :

* * *Struct(i).Firm = "Something"
* * *Struct(i).Adress1 = "10 Freeware St"

and so on...

I want to get the content of each cell of the line corresponding to the
code (which is unique). I think about collection as each value can be
off a different type (String, Currency, ...)

AB a écrit :



Perhaps a bit more light on this:
' I want to get, in VBA, the content of each cell of a line
corresponding
to a code and to get these values in a table of variables, or, better,
in a structure.

'
wouldn't hurt - i mean, there might be a few solutions depending on
what do you mean by 'table of variables' or 'in a structure'. For one,
you can just pull it straight into a dynamic array or you need to loop
through the ranges one by one and store each separately in a variable
or you can use collection/dictionary. The choice will depend on the
specifics. So, if you provide a bit more clarity on the paragraph i
quoted, i'm sure people here will come up with a great solution.
10 Freeware St10 Freeware St
On Jul 15, 10:18 am, Nemroth wrote:
Hello to everyone.


I've got an Excel sheet which is organized in a sheet of data. On the
first line, there are the titles in each column.
The first line contains, for each line, a unique code.


I want to get, in VBA, the content of each cell of a line corresponding
to a code and to get these values in a table of variables, or, better,
in a structure.


Can you show me how to do that, please ?


Thanks in advance.


Example of a line :


A * * * * *B * * * * C * * * * * * *D
Code * * * Firm * * *Adress 1 * * * City
GDPZ * * * Something 10 Freeware St New York- Hide quoted text -


- Show quoted text -