Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Macro Question 1

Status
Not open for further replies.

mtpisgah

Technical User
Nov 22, 2006
3
US
Perhaps someone here can point me in the right direction. I've just started trying to write macros in Excel and, umm, have a lot to learn.

I want to create a macro that merges any cell beginning with specific text with the cell directly above. As an example, I have a large Excel spreadsheet that looks similar to this:

1 This is a
2 xxxxsample
3 xxxxsentence.
4 This is also
5 xxxxa sample sentence.
6 This is
7 xxxxalso a
8 xxxxsample sentence.

and so on for several thousand rows, all in one column.

I want the cells beginning with "xxxx" to be merged (concatenated?) with the cell directly above, so that, if this were done for the entire worksheet, each sentence would all be in one cell, as opposed to spread out over multiple rows.

Does this make sense? Is it doable? Any suggestions?

Thanks for any help!
 



Hi,

Please post macro questions in VBA Visual Basic for Applications (Microsoft) forum707.

Skip,

[glasses] [red][/red]
[tongue]
 
Please post your VBA/Macro specific question in forum707, the VBA Visual Basic for Applications (Microsoft) Forum.

[tt]_____
[blue]-John[/blue][/tt]
[tab][red]The plural of anecdote is not data[/red]

Help us help you. Please read FAQ181-2886 before posting.
 


This can be solved without code...

If you data begins in COLUMN A, ROW 2, then in B2 and copy down...
[tt]
=IF(LEFT(A2,4)="xxxx",B1&" "&RIGHT(A2,LEN(A2)-4),A2)
[/tt]
in column c this formula
[tt]
=IF(AND(LEFT(A2,4)="xxxx",LEFT(A3,4)<>"xxxx"),1,0)
[/tt]
Then FILTER on column C = 1

VOLA!

Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top