Help with looping a recorded Marco

eelime127

New Member
Joined
Jul 15, 2014
Messages
4
I've recorded a Marco copying and pasting information from one cell to other cells and some of the copying functions paste to two cells. I just need this to loop through all information I'm copying from the the new cells.

Range("I1").Select
Selection.Copy
Range("D1").Select
ActiveSheet.Paste
Range("J1").Select
Application.CutCopyMode = False
Selection.Copy
Range("E1:E2").Select
ActiveSheet.Paste
Range("K1").Select
Application.CutCopyMode = False
Selection.Copy
Range("B1:B2").Select
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
First of all all the Selects don't need to be there

Code:
Range("You didn't show a place").Copy
Range("D1").Paste
Range("J1").Copy
Range("E1:E2").Paste
Range("K1").Copy
Range("B1:B2").Paste

As far as looping, What range are you trying to loop through. We will need additional information to help you out.
 
Upvote 0
You have things copying and pasting from different places to different places. Do you have 486 columns? because the only pattern I'm seeing from the small bit of data you have is I1, J1 and K1. In order to write a loop, there has to be some sort of pattern we can utilize to move through. So here is what we need.

1. What is the range of Data we are looping though (i.e. A1:Z1000)
2. What is the relationship between what is copied and where it should be pasted?
3. What identifier tells us when to paste into 2 cells instead of 1?
 
Upvote 0
XXXXX123456789
XXXXX123456789
XXXXX123456789
XXXXX123456789
XXXXX123456789

<tbody>
</tbody>
Here is an example of the data set that has 486 rows of information. This is the data that I need transferred onto an upload document that looks like this:

6789***XXXXX12345
6789******12345

<tbody>
</tbody>

So one row in the first table would equal these two rows. The asterisk is information that repeats so it can be disregarded. But the "6789" and "12345" are the values that need pasted in the range of cells.

Does this help?
 
Upvote 0
I'm still not totally clear as to how to determine which cells need to be pasted twice, or what your range of original data is. Or the format of your new data, is it a new list?
 
Upvote 0
The range of the original data is A1:C484 actually.

ABCD
16789
***XXXXX12345
26789******12345

<tbody>
</tbody>


The format of the new document with the copied information is exactly how it is above. It's a document to upload information into a database (the insert statements follow). Red is the information that needs to be copied to a range (A1:A2 and D1:D2) and the purple field is what only needs copied once (C1).

XXXXX123456789
XXXXX123456789
XXXXX123456789
XXXXX123456789
XXXXX123456789

<tbody>
</tbody>
 
Upvote 0
I think what is still confusing me is that you have 1 row of data repeated and nothing else showing me a pattern, the XXXXX is that the same thing over and over? It NEVER changes? And it only needs to go into C1 for the whoe spreadsheet? If that is the case all you are really trying to do is take A1 Copy to C1 then take Column B Copy it to column D and Column C Copied to Column A. With some infor in Column B. Is that correct?
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,289
Members
449,498
Latest member
Lee_ray

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