Copy and fill, repeat

TorrO

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

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

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>
 
Upvote 0

TorrO

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

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)
 
Upvote 0

TorrO

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

Forum statistics

Threads
1,186,909
Messages
5,960,536
Members
438,483
Latest member
Shahin Jack

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