Copy Range to Another Worksheet

jw102788

New Member
Joined
Dec 27, 2015
Messages
4
Greetings all people human and otherwise. I've got a question regarding copying a range of information from one worksheet to another with a piece of VBA code. I have a macro that does some data manipulation, and an excel sheet that updates as required to show those manipulations. The manipulations are a little lengthy, and I'm not including them since they are essentially mathematical operations. The mathematical operations are iterative in nature, and I am using a for loop to enable the expressions to converge to a solution. The issue I have is that I want to output specific results of the mathematical operations at every iteration of the for loop, and review to make sure that it is behaving correctly. Please see below.

Code:
Worksheets("Output").Range("A1:J176").Value = Worksheets("MathStuff").Range("A120:J296").Value

As it can be seen, I am basically wanting to transfer the values of a select range to a specific sheet labeled "Output". The above code works, and does what I need it to do, but it is not very flexible in conjunction with my for loop. That being said, I am looking for the syntax (or alternative approach) to transfer the information from the same range on the "MathStuff" worksheet that will change with the for loop as appropriate, but I want the flexibility to shift the range on the 'Output" sheet. Please see below.

Code:
Worksheets("Output").Range(Cells(1,1 + i),Cells(10,176 + i)).Value = Worksheets("MathStuff").Range("A120:J296").Value

This code gives me an error when I run it, probably due to my syntax (I think). The variable "i" is essentially a form of counter that, every time the math expressions are looped, the values shift down in the "Output" sheet, thus not overwriting the previously 'pasted' values. The result is that there are multiple sets of results that are reflected of the number of iterations of the "MathStuff" sheet went through to converge to a solution. I believe I am getting hung up on the syntax primarily, but I would appreciate any feedback. And thanks ahead of time for reading my small novel. :)
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
How about
Code:
Worksheets("Output").Range("A" & Rows.Count).End(xlUp).Offset(2).Resize(176, 10).Value = Worksheets("MathStuff").Range("A120:J296").Value
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,895
Members
449,097
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