How to use Filldown properly

ExcelPupper

Board Regular
Joined
Mar 2, 2020
Messages
112
Office Version
  1. 2019
Platform
  1. Windows
Hi I just want to confirm what's wrong on the code below particularly in the Filldown portion? It won't run properly when I tried it earlier.
Just to add, I am trying to copy the formula on Sheet1.Range (B2:E2) until the last row with data using column A of Sheet1 as reference.
Thanks!

VBA Code:
Sub CopyData()

Dim lr As Long, lr2 As Long

lr = Sheets(3).Range("B" & Rows.Count).End(xlUp).Row
lr2 = Sheets(1).Range("A" & Rows.Count).End(xlUp).Row


    Sheets(3).Range("B2:B" & lr).Copy
 
  
    Sheets(1).Range("A2").PasteSpecial Paste:=xlPasteValues
    Sheets(1).Range("A:A").RemoveDuplicates Columns:=1, Header:=xlNo
    Sheets(1).Range("B2:E" & lr2).FillDown
      
  

End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Ok, you are calculating the last row in sheets(1) before you add the data & remove the duplicates. Move that line to just before you fill down.
 
Upvote 0
Solution
Ok, you are calculating the last row in sheets(1) before you add the data & remove the duplicates. Move that line to just before you fill down.
Ohh okay, now I get it. Initially it captures the header of column A from Sheet1. Thanks for the tip!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,588
Messages
6,120,412
Members
448,960
Latest member
AKSMITH

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