If cell ends with $ then concatenate cell below.

HotLanta

Board Regular
Joined
Nov 3, 2005
Messages
176
Hi,

I have csv files. The data is always in column A. I would like to have a macro that runs down the rows and if a cell ends with "$" then concatenate the cell below. The data is in cell A1 down to about A500.

So if cell A21 ends with "$" then concatenate the contents of cell A22, then keep on going.

Would someone be able to help out with this?

Thank you
 
Yours and mine both assume that the final cell does not end with "$"
Good point about the last cell...I suppose the easiest way to address that possibility, for either formula, is to extend the range reference to include the cell below that last entry:
Excel Formula:
=DROP(TEXTSPLIT(CONCAT(A2:A17&IF(RIGHT(A2:A17,1)="$","","|")),,"|"),-1)
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I suppose the easiest way to address that possibility, for either formula, is to extend the range reference to include the cell below that last entry:
I don't like that option since it would include an empty cell in the spill range if the last cell does not end with $. This may affect subsequent formulas/results.
I also don't think worth worrying about at this stage since the OP asked for a vba solution & has one.
 
Upvote 0
Agreed, then it becomes messier...could add a conditional to check RIGHT(last cell,"$") and DROP either -1 or -2 from the final array, or perform the check in the initial step. But also not worth revising if there is no need.
 
Upvote 0

Forum statistics

Threads
1,224,819
Messages
6,181,153
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top