VBA to copy value in active cell down to end of data

Trebor200

Board Regular
Joined
Apr 21, 2015
Messages
67
Office Version
  1. 365
Platform
  1. Windows
I would like to take value in A12 and copy down to end of data set... The active cell can be anything other than A12 and the data set can also be many rows long..


Book1
AB
5ColourDate
6Blue17.11.2022
7Blue17.11.2023
8Blue17.11.2024
9Pink17.11.2025
10Pink17.11.2026
11Pink17.11.2027
12Brown17.11.2028
1317.11.2029
1417.11.2030
1517.11.2031
1617.11.2032
1717.11.2033
1817.11.2034
1917.11.2035
2017.11.2036
Sheet1
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
How about
VBA Code:
Sub Trebor()
   With Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub Trebor()
   With Range("A2:A" & Range("B" & Rows.Count).End(xlUp).Row)
      .SpecialCells(xlBlanks).FormulaR1C1 = "=r[-1]c"
      .Value = .Value
   End With
End Sub
Fluff,

When I tested your code on Trebor's data, it populted the blank cells, but it also populated the rows above the table (rows 2-4).
I think you may need to alter your code a little, i.e.
Rich (BB code):
   With Range("A5:A" & Range("B" & Rows.Count).End(xlUp).Row)
 
Upvote 0
Fluff,

When I tested your code on Trebor's data, it populted the blank cells, but it also populated the rows above the table (rows 2-4).
I think you may need to alter your code a little, i.e.
Rich (BB code):
   With Range("A5:A" & Range("B" & Rows.Count).End(xlUp).Row)
Yes... i figured that out and changed and works perfect.
 
Upvote 0

Forum statistics

Threads
1,214,947
Messages
6,122,411
Members
449,081
Latest member
JAMES KECULAH

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