macro relative position

Tody03

New Member
Joined
Jun 21, 2014
Messages
48
I have data that looks like that:
[TABLE="width: 72"]
<colgroup><col span="2"></colgroup><tbody>[TR]
[TD]a[/TD]
[TD="align: right"]1[/TD]
[/TR]
[TR]
[TD]b[/TD]
[TD="align: right"]5[/TD]
[/TR]
[TR]
[TD]c[/TD]
[TD="align: right"]3[/TD]
[/TR]
[TR]
[TD]d[/TD]
[TD="align: right"]7[/TD]
[/TR]
[TR]
[TD]e[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]f[/TD]
[TD="align: right"]2[/TD]
[/TR]
[TR]
[TD]g[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]h[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]i[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]j[/TD]
[TD]

[/TD]
[/TR]
</tbody>[/TABLE]
I want to fill the missing data in column b. that will be paralel to column a.
I wrote the attached macro
Range("B1").Select
Selection.End(xlDown).Select
Range("B7").Select
ActiveCell.FormulaR1C1 = "0"
Range("B8").Select
ActiveCell.FormulaR1C1 = "=R[-1]C"
Range("B8").Select
Selection.AutoFill Destination:=Range("B8:B16")
Range("B8:B16").Select
End Sub

my problem is that this macro does not work properly if column b is shorter or longer. How can i correct the macro that regardless the column length it will fill he missing data.
Thanks
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
How about
Code:
Sub Tody03()
   With Range("B:B")
      .SpecialCells(xlBlanks)(1).Value = 0
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
   End With
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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