driving is fun
New Member
- Joined
- Feb 8, 2018
- Messages
- 12
I wish to do a simple (I think!) Do-loop for the following: My simple program works as I want it to, but I think there is an easier way as I wish to repeat it 1000 times. Perhaps using some kind of loop? Do-Loop or otherwise. In short I want to:
At the end of the program I want t to return to cell A1.
My program is below:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Sub PasteSpecial_Examples()
Range("A1").Copy Range("B1")
Range("C1").Copy
Range("D1").PasteSpecial Paste:=xlPasteValues
Range("A2").Copy Range("B1")
Range("C1").Copy
Range("D2").PasteSpecial Paste:=xlPasteValues
Range("A3").Copy Range("B1")
Range("C1").Copy
Range("D3").PasteSpecial Paste:=xlPasteValues
Range("A4").Copy Range("B1")
Range("C1").Copy
Range("D4").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
</code>
- copy the contents from A1
- Paste them into B1
- copy cell C1 (it has a simple formula that acts on B1)
- copy the 'value' (only) from C1 into D1 (which will be a table of such values)
At the end of the program I want t to return to cell A1.
My program is below:
<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; white-space: inherit;">Sub PasteSpecial_Examples()
Range("A1").Copy Range("B1")
Range("C1").Copy
Range("D1").PasteSpecial Paste:=xlPasteValues
Range("A2").Copy Range("B1")
Range("C1").Copy
Range("D2").PasteSpecial Paste:=xlPasteValues
Range("A3").Copy Range("B1")
Range("C1").Copy
Range("D3").PasteSpecial Paste:=xlPasteValues
Range("A4").Copy Range("B1")
Range("C1").Copy
Range("D4").PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End Sub
</code>