PC Review


Reply
Thread Tools Rate Thread

Combine multiple cells into one cell.

 
 
jfcby
Guest
Posts: n/a
 
      12th Nov 2008
Hi,

In Excel 2003, I have a worksheet that has 50 rows and 7 columns of
data.

In G4 - G6 my data is formated like this:

MECH RM 125
MECH RM 548
KITCHEN 258

In the above example I would sometimes have 20 to 30 rows of data to
combine.

What I need F1 to look like: MECH RM 125, MECH 548, KITCHEN 258.

The formula I'm using now in F1 is: =G4 & ", " & G5 & ", " & G6

Is there a way to combine several rows into one without having to
manually type each row reference?

Thank for your help,
jfcby
 
Reply With Quote
 
 
 
 
Ken
Guest
Posts: n/a
 
      12th Nov 2008
jfcby

I think it would be a pretty difficult formula to include the commas
and much flexibility in your range. You could probably accomplish what
you want with a simple user defined function to which you would pass
the relevant cells and which would return the desired string.

Something like this should get you started

Function comb(R)

Dim m As String
Dim i As Integer

For i = 1 To R.Rows.Count
m = m & R.Cells(i, 1) & ", "
Next i

comb = m

End Function

Your worksheet would have =comb(range from which to string together
values). The passed range could be defined with counts or offsets or
whatever is most efficient way to describe the cells you want to
string together.

Good luck

Ken
Norfolk, Va

On Nov 12, 4:01*pm, jfcby <jamesf...@gmail.com> wrote:
> Hi,
>
> In Excel 2003, I have a worksheet that has 50 rows and 7 columns of
> data.
>
> In G4 - G6 my data is formated like this:
>
> MECH RM 125
> MECH RM 548
> KITCHEN 258
>
> In the above example I would sometimes have 20 to 30 rows of data to
> combine.
>
> What I need F1 to look like: MECH RM 125, MECH 548, KITCHEN 258.
>
> The formula I'm using now in F1 is: =G4 & ", " & G5 & ", " & G6
>
> Is there a way to combine several rows into one without having to
> manually type each row reference?
>
> Thank for your help,
> jfcby


 
Reply With Quote
 
jfcby
Guest
Posts: n/a
 
      13th Nov 2008
On Nov 12, 4:28*pm, Ken <krco...@aol.com> wrote:
> jfcby
>
> I think it would be a pretty difficult formula to include the commas
> and much flexibility in your range. You could probably accomplish what
> you want with a simple user defined function to which you would pass
> the relevant cells and which would return the desired string.
>
> Something like this should get you started
>
> Function comb(R)
>
> Dim m As String
> Dim i As Integer
>
> For i = 1 To R.Rows.Count
> * * m = m & R.Cells(i, 1) & ", "
> Next i
>
> comb = m
>
> End Function
>
> Your worksheet would have =comb(range from which to string together
> values). *The passed range could be defined with counts or offsets or
> whatever is most efficient way to describe the cells you want to
> string together.
>
> Good luck
>
> Ken
> Norfolk, Va
>
> On Nov 12, 4:01*pm, jfcby <jamesf...@gmail.com> wrote:
>
>
>
> > Hi,

>
> > In Excel 2003, I have a worksheet that has 50 rows and 7 columns of
> > data.

>
> > In G4 - G6 my data is formated like this:

>
> > MECH RM 125
> > MECH RM 548
> > KITCHEN 258

>
> > In the above example I would sometimes have 20 to 30 rows of data to
> > combine.

>
> > What I need F1 to look like: MECH RM 125, MECH 548, KITCHEN 258.

>
> > The formula I'm using now in F1 is: =G4 & ", " & G5 & ", " & G6

>
> > Is there a way to combine several rows into one without having to
> > manually type each row reference?

>
> > Thank for your help,
> > jfcby- Hide quoted text -

>
> - Show quoted text -


Thank you for your help and function Ken.

I do not know call or run a function. I researched function in this
forum and in the Excel help file and still do not understand how
functions work.

Is it possible to convert the function into a macro?

Thank you for your help,
jfcby
 
Reply With Quote
 
jfcby
Guest
Posts: n/a
 
      13th Nov 2008
On Nov 13, 12:39*pm, jfcby <jamesf...@gmail.com> wrote:
> On Nov 12, 4:28*pm, Ken <krco...@aol.com> wrote:
>
>
>
>
>
> > jfcby

>
> > I think it would be a pretty difficult formula to include the commas
> > and much flexibility in your range. You could probably accomplish what
> > you want with a simple user defined function to which you would pass
> > the relevant cells and which would return the desired string.

>
> > Something like this should get you started

>
> > Function comb(R)

>
> > Dim m As String
> > Dim i As Integer

>
> > For i = 1 To R.Rows.Count
> > * * m = m & R.Cells(i, 1) & ", "
> > Next i

>
> > comb = m

>
> > End Function

>
> > Your worksheet would have =comb(range from which to string together
> > values). *The passed range could be defined with counts or offsets or
> > whatever is most efficient way to describe the cells you want to
> > string together.

>
> > Good luck

>
> > Ken
> > Norfolk, Va

>
> > On Nov 12, 4:01*pm, jfcby <jamesf...@gmail.com> wrote:

>
> > > Hi,

>
> > > In Excel 2003, I have a worksheet that has 50 rows and 7 columns of
> > > data.

>
> > > In G4 - G6 my data is formated like this:

>
> > > MECH RM 125
> > > MECH RM 548
> > > KITCHEN 258

>
> > > In the above example I would sometimes have 20 to 30 rows of data to
> > > combine.

>
> > > What I need F1 to look like: MECH RM 125, MECH 548, KITCHEN 258.

>
> > > The formula I'm using now in F1 is: =G4 & ", " & G5 & ", " & G6

>
> > > Is there a way to combine several rows into one without having to
> > > manually type each row reference?

>
> > > Thank for your help,
> > > jfcby- Hide quoted text -

>
> > - Show quoted text -

>
> Thank you for your help and function Ken.
>
> I do not know call or run a function. I researched function in this
> forum and in the Excel help file and still do not understand how
> functions work.
>
> Is it possible to convert the function into a macro?
>
> Thank you for your help,
> jfcby- Hide quoted text -
>
> - Show quoted text -


This is my macro working solution:

Sub CombineCells()
'Combines data from multiple selected cells into one cell.

Dim firstCell As Range
Dim lastCell As Range
Dim offsetCell As Range
Dim i As Integer

Set firstCell = Selection(1)
Set lastCell = Selection(Selection.Count)
Set offsetCell = Selection(Selection.Count).Offset(0, 1)

If lastCell > 1 Then
For i = 1 To Selection.Count
If offsetCell = "" Then
offsetCell = offsetCell & Selection(i)
Else 'If offsetCell > "" Then
offsetCell = offsetCell & ", " & Selection(i)
End If
Next
Else 'If lastCell <= 1 Then
MsgBox "Select 2 or more cells to continue!"
End If
End Sub

Thanks for your help,
jfcby
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to combine multiple cells into on cell papercut Microsoft Excel Worksheet Functions 8 15th Jan 2009 10:54 PM
How to combine multiple rows of text cells into one cell sumamahe_99@yahoo.com Microsoft Excel Misc 2 19th Oct 2006 01:19 PM
How do I combine the contents of multiple cells in one cell? =?Utf-8?B?RGViYmll?= Microsoft Excel Worksheet Functions 3 16th Dec 2005 10:57 PM
Combine multiple cells into one cell range. =?Utf-8?B?Z3JhZHk4OA==?= Microsoft Excel Worksheet Functions 1 12th Oct 2005 08:03 PM
Combine multiple cells into one cell Michael Tomasura Microsoft Excel Worksheet Functions 2 23rd Aug 2003 05:17 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:28 PM.