Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
PJ PJ is offline
external usenet poster
 
Posts: 112
Default Simple Concatenation

I want to concatenate the text from cells C, D & E17 into my csz variable.
What I have below works, but do I have to specify the sheet name for each
cell reference or is there a way to shorten this?

csz = Sheets("Sheet1").Range("C17") & Sheets("Sheet1").Range("D17") &
Sheets("Sheet1").Range("E17")

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
Vj Vj is offline
external usenet poster
 
Posts: 54
Default Simple Concatenation

Use with statement

with WorkSheetObject
varname = .Cell1 & .Cell2
end with

"PJ" wrote:

I want to concatenate the text from cells C, D & E17 into my csz variable.
What I have below works, but do I have to specify the sheet name for each
cell reference or is there a way to shorten this?

csz = Sheets("Sheet1").Range("C17") & Sheets("Sheet1").Range("D17") &
Sheets("Sheet1").Range("E17")

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Simple Concatenation

with worksheets("sheet1")
csz = .Range("C17").value & .Range("D17").value & .Range("E17").value
end with

I like to specify the property I want to use, too. But maybe you'd want
..text???


PJ wrote:

I want to concatenate the text from cells C, D & E17 into my csz variable.
What I have below works, but do I have to specify the sheet name for each
cell reference or is there a way to shorten this?

csz = Sheets("Sheet1").Range("C17") & Sheets("Sheet1").Range("D17") &
Sheets("Sheet1").Range("E17")

Thanks


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Simple Concatenation


VJ;535948 Wrote:
Use with statement

with WorkSheetObject
varname = .Cell1 & .Cell2
end with


which translates to:
With Sheets("Sheet1")
csz = .Range("C17") & .Range("D17") & .Range("E17")
End With


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: http://www.thecodecage.com/forumz/member.php?userid=558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=147318

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Simple Concatenation

Dim ws as Worksheet, csz as String
Set ws = Sheets("Sheet1")
csz = ws.Range("C17") & ws.Range("D17") & ws.Range("E17")
Msgbox csz


If this post helps click Yes
---------------
Jacob Skaria


"PJ" wrote:

I want to concatenate the text from cells C, D & E17 into my csz variable.
What I have below works, but do I have to specify the sheet name for each
cell reference or is there a way to shorten this?

csz = Sheets("Sheet1").Range("C17") & Sheets("Sheet1").Range("D17") &
Sheets("Sheet1").Range("E17")

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Simple Concatenation

And, for a different method, which can easily be expanded to as many
contiguous cells in a row (just change the Range)...

Set R = Sheets("Sheet1").Range("C17:E17")
With WorksheetFunction
csz = Join(.Transpose(.Transpose(R)), "")
End With

If you Dim your variables (and you should), Dim csz as a String and R as a
Range. Now, the above code is good for rows; if you had a contiguous range
of cells in a column, then you would need to remove one of the Transpose
function calls (and, with that simplification, we could get rid of the
With..EndWith structure as well...

Set R = Sheets("Sheet1").Range("A10:A99")
csz = Join(WorksheetFunction.Transpose(R), "")

Also, using either of the above methods (depending on if your data is in a
row or in a column), you can easily specify a delimiter to place between
your cell values... just replace the "" with whatever that delimiter should
be (in quotes, of course). For example, to put a comma between the values,
just use "," instead of "".

--
Rick (MVP - Excel)


"PJ" wrote in message
...
I want to concatenate the text from cells C, D & E17 into my csz variable.
What I have below works, but do I have to specify the sheet name for each
cell reference or is there a way to shorten this?

csz = Sheets("Sheet1").Range("C17") & Sheets("Sheet1").Range("D17") &
Sheets("Sheet1").Range("E17")

Thanks


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple concatenation including date mike_vr Excel Discussion (Misc queries) 3 November 9th 09 03:53 PM
Concatenation Muthalaly Excel Discussion (Misc queries) 2 June 24th 08 12:57 PM
Concatenation ATHER Excel Worksheet Functions 2 May 19th 08 11:27 PM
Concatenation JPS Excel Worksheet Functions 3 May 4th 08 07:35 AM
Help with Concatenation Tabit Excel Worksheet Functions 8 August 17th 07 06:52 PM


All times are GMT +1. The time now is 11:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"