0

There is any possibility to store an entire column in a string variable? I need that variable as a string and not range type. I mean, something like this:

    Dim myStrVar As String
    myStrVar = Sheets("Sheet1").Range("A:A")
    MsgBox myStrVar

This code error is: Type mismatch I want to specify that my column contains only text (string type).

If possible, how can I do this?? Thank you!

2
  • What exactly are you trying to do? A Range is a series of cells with values so it makes sense you cant just assign them to a string since there is more than one (possibly over a million cells in 1 column depending on you version of Excel). Are you trying to concatenate the values of every cell? Commented Sep 18, 2014 at 9:10
  • @psubsee2003: I want to use all the cells information from that column to send an email with that information. So I need that variable that will be my email message. And yes, I want to concatenate all the cells content and store it in a variable Commented Sep 18, 2014 at 9:21

1 Answer 1

1

You can do like this

a = 2
do while cells(a,1)<>""
mystrvar = mystrvar & cells(a,1)
a = a +1
msgbox mystrvar
loop
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.