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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
If you require a macro, a tested alternative:

Code:
Public Sub FillColA()
Dim rng1    As Range, _
    rng2    As Range
Application.ScreenUpdating = False
Set rng1 = Range("A1")
Do
    If rng1.Offset(1, 0).Value = "" Then
        Set rng2 = rng1.Offset(1, 0).End(xlDown).Offset(-1, 0)
        Range(rng1, rng2).Value = rng1
        Set rng1 = rng2.Offset(1, 0)
        Set rng2 = Nothing
    End If
Loop Until rng1 = Range("A" & Rows.Count).End(xlUp)
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Ah, that wasn't mine anyway. Post #4.

The reason I ask is because your original post said you wanted to go to the bottom of the worksheet and I'm not sure if the 'manual' method will do that, owing to the way 'blank cells' are defined by Excel. If you only need it to fill to the bottom of the current dataset then that would be okay.
 
Upvote 0
brans1982 excuse me...it works perfectly.

MrKowz your first solution helped me and thats all I needed.

Now am responding to all the solutions for being kind to all these kind effort everyone is giving to my problem :)

Thank you again guys :)
 
Upvote 0
This way, it doesn't matter what version you use
Code:
Sub LoopTest()
    For i = 1 To Rows.Count
        If Cells(i, 1) = "" Then
            Cells(i, 1) = Cells(i - 1, 1)
        End If
    Next i
End Sub
 
Upvote 0
brans1982 excuse me...it works perfectly.

MrKowz your first solution helped me and thats all I needed.

Now am responding to all the solutions for being kind to all these kind effort everyone is giving to my problem :)

Thank you again guys :)

Lol, sometimes we can be a little too helpful!

W
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,291
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