Copy and fill, repeat

TorrO

Board Regular
Joined
Feb 13, 2003
Messages
118
Office Version
  1. 2013
Platform
  1. Windows
Hi

challange:

I have a sheet which look like this:
Only row a and b
Bok1
ABCD
1****10
212
37
490
5George23
685
746
898
9456
1089
11534
124
1355
1454
15854
16Bill354
17354
18354
1985
208
21546
Ark1


The macro i need make the sheet look like this
Bok1
ABCDE
1****10
2****12
3****7
4****90
5George23
6George85
7George46
8George98
9George456
10George89
11George534
12George4
13George55
14George54
15George854
16Bill354
17Bill354
18Bill354
19Bill85
20Bill8
21Bill546
Ark1


Thanks

T
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
hi!
Try this one!

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> Fillx()
<SPAN style="color:#00007F">Dim</SPAN> c <SPAN style="color:#00007F">As</SPAN> Range
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> c <SPAN style="color:#00007F">In</SPAN> Range("A2:a" & Range("a65536").End(xlUp).Row)
<SPAN style="color:#00007F">If</SPAN> c = "" <SPAN style="color:#00007F">Then</SPAN>
    c = c.Offset(-1, 0)
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN>
<SPAN style="color:#00007F">Next</SPAN> c
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
 
Upvote 0
Thanks

it worked but the last name 'Bill' is not copied

Result:
Bok1
ABCDE
1****10
2****12
3****7
4****90
5George23
6George85
7George46
8George98
9George456
10George89
11George534
12George4
13George55
14George54
15George854
16Bill354
17354
18354
1985
208
21546
Ark1
 
Upvote 0
hi!
Change this line
Code:
For Each c In Range("A2:a" & Range("a65536").End(xlUp).row)
to
For Each c In Range("A2:a" & Range("b65536").row
End(xlUp).row)
 
Upvote 0
Thanks Sixth Sense, it worked!

Here is the code

Sub Fillx()
Dim c As Range

For Each c In Range("A2:a" & Range("b65536").End(xlUp).Row)
If c = "" Then
c = c.Offset(-1, 0)
End If
Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

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