macro loop help

opie971

New Member
Joined
Feb 7, 2010
Messages
8
I have a problem that I am trying to understand. I have a worksheet with about 3600 numbers that I want to do mathematical equations to. I have setup my worksheet to complete all of the math if I can get the numbers into one specific cell. I have worked up a loop macro to get this done quicker but I am stuck on one problem. This is what my macro looks like now:
do
activecell.offset(1,0).select
activecell.copy
range("b22").select
activesheet.paste
????
loop
The problem I have is how to get the active cell for coping back to the list of numbers. I thought about using some sort of (X,X) but am only getting stuck. If I use offset I can only get the numbers duplicated to the other row. Any help is appreciated. Thanks
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Thanks for the help! I really do not know how to explain it other than I want to place a number in a specific cell and then place the number below it into the same cell and then the number below the second number in the same cell and so on and so forth. Basically I'm looking for an easy macro loop to copy/paste a group of numbers into a single cell one at a time. Sorry that I do not have a better explanation.
 
Upvote 0
Look at this macro:
do
activecell.offset(1,0).select
activecell.copy
activecell.offset(-1,0).select
activesheet.paste
acrivecell.offset(1,1).select
loop
This macro will copy all the numbers from one column to the next column. Instead of placing the numbers into the next column I want to place the numbers into a specific cell, then all of the math gets done, and the answers get placed into a column farther down the worksheet. At that time I will copy the final column onto a new worksheet one at a time. I am pretty sure that a do..then..next macro will do it but I am unsure about the start. I will figure out the paste from one sheet to the next later. Thank you
 
Upvote 0
Thanks for the help but I figured out the solution to my problem. The macro I created looks like this
for x=1 to 100 (or however many)
cells(x,3).select (you can change column by using a different number)
activecell.copy
range("e4").select (e4 can be the cell you want the number in)
activesheet.paste
next x
I am putting this up so that it may help other people. Hopefully. If anyone has any ideas about how to make this work better or easier, I will take any advice.
Thanks for all the help!!! :)
 
Upvote 0
Hi Opie,

Given your first post, it appears that you are calculating different things with the changing value of E4.

You do not need to Select, Activate, Copy, Paste... Simply assign the val of each cell in the looped range to E4; something like:

<font face=Courier New><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN><br>    <br><SPAN style="color:#00007F">Sub</SPAN> exa()<br><SPAN style="color:#00007F">Dim</SPAN> x <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    <SPAN style="color:#00007F">For</SPAN> x = 1 <SPAN style="color:#00007F">To</SPAN> 100<br>        Range("E4").Value = Cells(x, 3).Value<br>        <SPAN style="color:#007F00">'// Presumably, you are doing something with the val in E4 here...</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> x<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Hope that helps,

Mark
 
Upvote 0
Thank you very much. That is a much easier and simpler code than the one that I had. You have helped where others have said that it was not possible to do that. Thanks again
 
Upvote 0

Forum statistics

Threads
1,215,256
Messages
6,123,914
Members
449,132
Latest member
Rosie14

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