range of cells concatenated to one field?

cccbzg

Board Regular
Joined
Oct 5, 2014
Messages
68
Office Version
  1. 365
Platform
  1. Windows
Hello,

I would like to write the value of a range I've selected to a particular cell. In other words, I want to write the value of the entire range to a cell. So for example, the range may include col A rows 3,4, and 5. Can this concatenated range be treated as one value to be output to a cell?
Can't seem to get that to work. Tried Valrange1 = Range("A" & s5row & ":A" & drow).Value, and then Cells(arow, 48) = Valrange1, but that only got me the first value in the range. Thought perhaps I needed DIM Valrange1 AS Range, but that caused an error.



Here's how I set up the range:



With Sheets("INPUT").Range("A" & s5row & ":A" & drow)

Set DXrng = .Find(What:=DDXit, _

After:=.Cells(.Cells.Count), _

LookIn:=xlValues, _

LookAt:=xlPart, _

SearchOrder:=xlByRows, _

SearchDirection:=xlNext, _

MatchCase:=False)

End With



Help much appreciated.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
I use a User-Defined Formula for this, as Excel doesn't have a native operator:
Code:
Function ConcatAll(rgVals as Range, stSep as String) as String

Dim cl as Range

For Each cl in rgVals
   If cl.Value <> "" Then
      ConcatAll = ConcatAll & cl.Value & stSep
   End If
Next cl

ConcatAll = Left(ConcatAll, Len(ConcatAll) - Len(stSep))

End Function

The stSep just allows me to control what is used as a separator - semi-colons for names on e-mail, commas or spaces for other purposes, etc.
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

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