+ Reply to Thread
Results 1 to 5 of 5

Place text from multiple columns into one cell based on another columns value

  1. #1
    Registered User
    Join Date
    12-17-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    3

    Place text from multiple columns into one cell based on another columns value

    Hi Guys

    Can anyone help me with this as I have a long complicated formula that works, but is a bit of a pain to edit when needed.

    I have one column with quantities os speakers being installed in a room with values in from D3 to D39. This may have a number in it or may be blank.

    What I want to get to is a formula that goes through this column and only writes a line in a cell if there is a number in this column.

    the line that is written in the cell will be from the cells to the left of the quantity column and will also include the quantity column.

    So for example the output would be a single cell containing

    Ground Floor: Living Room Celing x 2
    Ground Floor: Kitchen Celing x 2

    I have found that as long as word wrap is turned on the Char(13) will insert a carriage return to nicely put all these all on separate lines.

    I hope you can help.

    Thanks

    Minesh

  2. #2
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Place text from multiple columns into one cell based on another columns value

    Sorry the description does not leave me 100% clear on what is needed, and additionally a sample workbook would make it much easier to understand what you have and what you need.
    Please help by:

    Marking threads as closed once your issue is resolved. How? The Thread Tools at the top
    Any reputation (*) points appreciated. Not just by me, but by all those helping, so if you found someone's input useful, please take a second to click the * at the bottom left to let them know

    There are 10 kinds of people in this world... those who understand binary, and those who don't.

  3. #3
    Registered User
    Join Date
    12-17-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Place text from multiple columns into one cell based on another columns value

    Screen Shot 2015-03-04 at 21.17.53.png

    Hi All,

    Please see the screenshot.

    Hopefully this makes it easier to se what I am trying to get to.

    Thanks

    Minesh

  4. #4
    Forum Expert Arkadi's Avatar
    Join Date
    02-13-2014
    Location
    Smiths Falls, Ontario, Canada
    MS-Off Ver
    Office 365
    Posts
    5,059

    Re: Place text from multiple columns into one cell based on another columns value

    Yikes that'd be one messy formula if it is possible... Are you open to a macro? If so I can take a look, but can you provide an actual workbook with some data (does not have to be real, just organized like the real stuff)? where would the output go?

  5. #5
    Registered User
    Join Date
    12-17-2013
    Location
    United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: Place text from multiple columns into one cell based on another columns value

    Hi All,

    A very knowledgeable member of experts exchange Saurabh Singh Teotia wrote the following for me and it works perfectly.

    Function combine(r As Range, z As Long, k As Long, a As Long)

    Dim c As Range

    For Each c In r
    If Trim(c.Value) <> "" Then

    If combine = "" Then
    combine = c.Offset(0, z).Value & ": " & c.Offset(0, k).Value & " " & c.Offset(0, a).Value & " x " & c.Value
    Else
    combine = combine & Chr(10) & c.Offset(0, z).Value & ": " & c.Offset(0, k).Value & " " & c.Offset(0, a).Value & " x " & c.Value

    End If

    End If

    Next c

    End Function


    Arkadi - Thanks for trying, yes you were right that it is not easily possible without a very very long messy formula, but this little but of VB made it much easier.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Filtering Columns based on Cell Value for multiple columns
    By MikeRoot in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-31-2014, 08:07 AM
  2. [SOLVED] Place data from multiple columns in same row
    By macro12 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-19-2013, 10:18 PM
  3. Replies: 0
    Last Post: 08-03-2012, 04:31 PM
  4. Replies: 0
    Last Post: 05-12-2011, 04:24 PM
  5. Text to columns where a formula is in place
    By Gooford in forum Excel General
    Replies: 4
    Last Post: 09-23-2009, 10:17 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1