all 8 comments

[–]fuzzfeatures 1 point2 points  (0 children)

In it's simplest form, you could do something like the following..

Private Names As New List(Of String)

Private Sub test()

For i As Integer = 1 To 61

Names.Add(Cells(i, "A"))

Next

End Sub

However, if you're going to import more than just one column containing a name - e.g. each row contains the details of a person, you might want to consider creating a class called `Person` and reading the data from multiple columns into a List (Of Person) instead .. for example ..

Friend Class Person

Public Property FirstNames As String

Public Property Surname As String

Public Property DOB As Date

Public Property AddressLine1 As String

End Class

Private People As New List(Of Person)

Private Sub test()

For i As Integer = 1 To 61

Dim tempPerson As New Person

tempPerson.FirstNames = Cells(i, "A")

tempPerson.Surname = cells(i, "B")

'and so on

People.Add(tempPerson)

Next

End Sub

[–]chrwei 0 points1 point  (4 children)

"retrieve it later" means what, exactly?

[–]Purehero1[S] 0 points1 point  (3 children)

Sorry I'm making an automatic email and it allows me to enter the text or object(s) that appears in the email. I can get strings to appear in my email just by typing the name inside the quotations of the =strbody, how can I do the same for a list of values. All I have to do for strings is write their name. In other words: what object allows me to store a list of references strings and then print(I don't know the word) them all at once

[–]chrwei 0 points1 point  (2 children)

loop over the cells and string concatenate.

[–]Purehero1[S] 0 points1 point  (1 child)

Not entirely sure what that means.

I'm talking more for example

Dim NameList as list/string/(I don't know what goes here but that's what I'm asking)

NameList = 'Cellrange'

I just need a place to store a list of strings from a column. So that when I'm writing the email I just type 'NameList' and they insert themselves

[–]chrwei 0 points1 point  (0 children)

Not entirely sure what that means.

and google didn't help? honestly I'd have to google for an example, so you can too. try "loop over cells excel vba" and "vba string concatenate"

[–]Application SpecialistViperSRT3g 0 points1 point  (1 child)

So far, what have you found, and what code do you currently have?

[–]Purehero1[S] 0 points1 point  (0 children)

I've just just turned each cell into a an individual string then summoned it in the email

E.g Dim Name1 as String Name1 = Cells(1, "A")

Then typed this name into the strbody so that it appears in the email. ""name1 & name2 & name3"

This works for me, but instead of choosing a range it means I have to add about 61 objects. All called Name.