selection cell phaste formula till last row

jaik22

Board Regular
Joined
Sep 23, 2016
Messages
102
Code:
Range("D2").Select
    Lastrow1 = Range("C" & Rows.Count).End(xlUp).Row
   Selection.End(xlDown).Offset(1, 0).Select
   Selection.Formula = "=0000"

Hi guys, I am trying to putting value on below last row of D column and would like to extend value till last row of the column.
Usually column C has more data than D, so D has few more columns to fill up. I got the part fill data on below last row, but can't figure it out to extend data through last row.

Is there any function for this?

Thank you
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Something like

Code:
Sub test()
    Dim LastRow1 As Long
    LastRow1 = Range("C" & Rows.Count).End(xlUp).Row
    Range("D2:D" & LastRow1).Formula = "=0000"
End Sub
 
Upvote 0
Code:
[TABLE="width: 128"]
 <colgroup><col width="64" span="2" style="width:48pt"> </colgroup><tbody>[TR]
  [TD="width: 64"]Column C

PASSS[/TD]
  [TD="width: 64, align: right"] 
ColumnD
5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD="align: right"]5242[/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD][/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD][/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD][/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD][/TD]
 [/TR]
 [TR]
  [TD]PASSS[/TD]
  [TD][/TD]
[/TR]
</tbody>[/TABLE]

My dataset is looking like this.
I need to keep D column data and put 0 after the last row of D column.
Then I would like to extend 0 to the last row.

Thank you
 
Upvote 0
How about you just filter column D for blanks and paste a zero?
 
Upvote 0
Code:
Range("D1:D" & Range("C" & Rows.Count).End(xlUp).Row).SpecialCells(4).Value = 0
 
Upvote 0
Or if you are sure you want a formula (can't think why with that formula) then...

Code:
Range("D1:D" & Range("C" & Rows.Count).End(xlUp).Row).SpecialCells(4).Formula = "=0000"

or if there are spaces amongst the D column values then


Code:
Range(Cells(Range("D" & Rows.Count).End(xlUp).Row, "D").Offset(1), Cells(Range("C" & Rows.Count).End(xlUp).Row, "C")).SpecialCells(4).Formula = "=0000"

Obviously the above falls down if the cells aren't truly blank (i.e. formulas resulting in a "" aren't truly blank).
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,774
Members
452,353
Latest member
strainu

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