write range value to a cell

cccbzg

Board Regular
Joined
Oct 5, 2014
Messages
66
Office Version
  1. 365
Platform
  1. Windows
Hi,

I would like to write the value of a range I've selected to a particular 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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

cccbzg

Board Regular
Joined
Oct 5, 2014
Messages
66
Office Version
  1. 365
Platform
  1. Windows
can get the address with, your cell = DXrng.address(0,0)

May not have explained the situation well. 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?


Sorry for the confusion. Thanks!
 
Upvote 0

Stridhan

Well-known Member
Joined
Mar 5, 2014
Messages
568
i would do something like this
Code:
Sub test()

Dim mArray As Variant, c As Variant, newVal As String
mArray = Range("A1:A5").Value

For Each c In mArray
    newVal = newVal & c & " "
Next c
Range("B1").Value = Trim(newVal)

End Sub
 
Upvote 0

Forum statistics

Threads
1,195,619
Messages
6,010,736
Members
441,567
Latest member
Flitbee

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
Top