copy-paste vba? do-loop?

gledister

Board Regular
Joined
Mar 21, 2011
Messages
173
we have this column:
Excel Workbook
A
11
2
3
42
5
6
7
8
9
103
11
12
13
14
15
16
17
18
195
20
21
22
23
24
25
26
27
Sheet1


and what we want is:

Excel Workbook
A
11
21
31
42
52
62
72
82
92
103
113
123
133
143
153
163
173
183
195
205
215
225
235
245
255
265
275
285
Sheet1



and the last one goes till the end of the worksheet.

Anyone got any idea?!
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Try this:
  1. Highlight Column A
  2. Edit>Goto (if you use Excel 2007, you can find GoTo under Home>Find&Select)
  3. Special>Blanks
  4. Place in the formula bar =A1
  5. Use CTRL+ENTER to enter the formula
 
Upvote 0
What definies the number of 5's you copy down? This can do as a start:
Code:
Sub Assimilation()
Range("A1").Copy Range("A1").Resize(3, 1)
Range("A4").Copy Range("A4").Resize(6, 1)
End Sub
But for completeness, you probably want to place this into a loop with a variable that works out how many rows you want to copy down but that's difficult to know when you don't define your end/last row
 
Upvote 0
Something like:

Code:
Sub test2()
    Application.ScreenUpdating = False
    With Columns(1)
        .Cells(.Rows.Count, 1).Value = .Cells(.Rows.Count, 1).End(xlUp).Value
        .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=r[-1]c"
        .Value = .Value
    End With
End Sub
 
Upvote 0
This loop will take a while but it will do the trick...

Sub LoopTest()

For i = 1 to 1048576 (65536 - Excel 2003 or less)

If Cells(i,1) = "" Then

Cells(i,1) = Cells(i-1,1)

End If

Next i

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,285
Members
452,902
Latest member
Knuddeluff

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