Range transfer

alee001

Board Regular
Joined
Sep 9, 2014
Messages
154
Office Version
  1. 2010
Platform
  1. Windows
How to transfer the range to other range/location after calculation? Thanks.
VBA Code:
Sub sample()
Dim rng As Range
Dim r As Range
Dim i As Long
Dim arr() As Variant
Set rng = Application.Range("B2:D11")
ReDim arr(rng.Count)
For Each r In rng
    i = i + 1
    arr(i) = r + 1
Next
Cells(6, 7).Resize(10, 3) = arr() 'how to transfer?
Set rng = Nothing
Set arr = Nothing
End Sub
 

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"
What do you mean by "after calculation"? Tell us a bit more about what you have and what you are trying to achieve.

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version[. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0
What do you mean by "after calculation"? Tell us a bit more about what you have and what you are trying to achieve.

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version[. (Don’t forget to scroll down & ‘Save’)
Thanks reply, I used to Excel 2010 with Win7.
I don't know how to transfer the answer on arr() to Cells(6, 7).Resize(10, 3)?
 
Upvote 0
I used to Excel 2010 with Win7
Please put that in your Account details as I described before, then the information is always available to helpers. ;)

1616480795969.png



I don't know how to transfer the answer on arr() to Cells(6, 7).Resize(10, 3)?
If that is all you are trying to do, try

VBA Code:
Sub TestMove()
  Cells(6, 7).Resize(10, 3).Value = Range("B2:D11").Value
End Sub
 
Upvote 0
Since your "copy to" range is fixed in location and size, you could also do this...
VBA Code:
Sub TestMove2()
  [G6:I15] = [B2:D11]
End Sub
If you are uncomfortable using the square bracket notation, you could also do it this way...
VBA Code:
Sub TestMove3()
  Range("G6:I15").Value = Range("B2:D11").Value
End Sub
 
Upvote 0
Since your "copy to" range is fixed in location and size, you could also do this...
VBA Code:
Sub TestMove2()
  [G6:I15] = [B2:D11]
End Sub
If you are uncomfortable using the square bracket notation, you could also do it this way...
VBA Code:
Sub TestMove3()
  Range("G6:I15").Value = Range("B2:D11").Value
End Sub

Not value transfer, why Cells(6, 7).Resize(10, 3) range cannot got the answer?
 
Upvote 0
Range("G6:I15") and Cells(6,7).Resize(10,3) describe exactly the same range of cells. The shortcut notation for Range("G6:I15") is [G6:I15] and [B2:D11] is a shortcut notation for Range("B2:D11"). Now, with that said, I had an error in my TestMove2 code... I forgot the specify the Value property...
VBA Code:
Sub TestMove2()
  [G6:I15] = [B2:D11].Value
End Sub
 
Upvote 0
You can input any value in Range("B2:D11") then run my simple code, you will found that the range on Cells(6, 7).Resize(10, 3) cannot got the answer by array...
 
Upvote 0
You can input any value in Range("B2:D11") then run my simple code, you will found that the range on Cells(6, 7).Resize(10, 3) cannot got the answer by array...
Yes, we can see that and that is why we have been offering you simple alternative codes that do transfer the data. :)

If you really must use an array then you can do it like this

VBA Code:
Sub sample2()
  Dim arr As Variant
 
  arr = Range("B2:D11").Value
  Cells(6, 7).Resize(UBound(arr), UBound(arr, 2)).Value = arr
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,093
Latest member
dbomb1414

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