Copy and fill, repeat

TorrO

Board Regular
Joined
Feb 13, 2003
Messages
103
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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
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>
 

TorrO

Board Regular
Joined
Feb 13, 2003
Messages
103
Office Version
  1. 2013
Platform
  1. Windows
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
 

SIXTH SENSE

Well-known Member
Joined
Oct 29, 2003
Messages
1,883
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)
 

TorrO

Board Regular
Joined
Feb 13, 2003
Messages
103
Office Version
  1. 2013
Platform
  1. Windows
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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,095
Messages
5,768,053
Members
425,451
Latest member
JohnBrooksBiddle

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
Top