0

I have a column with dates in a table called Transactions in Excel. I have a column called transactions and I would like to iterate through the descriptions and assign them to a string. My test code is as below and I am getting a error 1004.

For i = 1 To Range("Transactions").Rows.Count
    ' Set group to the value returned from the DEscription Table
    strGroup = Range("Transactions[Description]")(i)
Next i

I need help i tried adding .Value at the end and it did not help anything

I want to basically search every cell in a particular column for specific words and if they match. Copy the text to a new column. So that's why I want to get every description as a string and then use it as a parameter in the InStr function

7
  • you can't have a range assigned to a string. You can assign a value from a range to a string. Commented Aug 21, 2017 at 14:42
  • I tried using the range.Value but that didnt help either Commented Aug 21, 2017 at 14:45
  • A String is one value. A Range is one object representing one or more cells in a worksheet; Range has a Value property, but if the range is for more than one cell then it gets you an array of values, which you can't legally assign to a String. By the way, iterating cells the way you're doing here, is the single slowest way to go about it. And even if the assignment was legal, you're overwriting it with every new iteration. Commented Aug 21, 2017 at 14:56
  • Ok I actually want to overwrite the value every time. But then I tried using the list object way but I wasn't getting what I wanted. What do you suggest Commented Aug 21, 2017 at 15:08
  • You definitely don't want to overwrite the value every time; otherwise when the loop exits, strGroup will only ever contain whatever the last iteration assigned it to, which defeats the entire point of looping in the first place (just read the last value if what you want is the last value). I'd love to help, but I've no idea what you're asking / trying to do. Commented Aug 21, 2017 at 15:30

1 Answer 1

2

maybe join(application.transpose(range("a1:a100").value)," ") not sure how it will perform at various sizes, but 100 rows was ok.

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks I will try it.
What happened/were you expecting?
I want to basically search every cell in a particular column for specific words and if they match. Copy the text to a new column. So that's why I want to get every description as a string and then use it as a parameter in the InStr function
You should add that bit to your question.

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.