VBA Error with .FillDown

sax2play

New Member
Joined
Mar 13, 2021
Messages
16
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I am having an error where .FillDown is deleting my cell data when the first row=last row. Please see code below:

VBA Code:
Application.ScreenUpdating = False
    Dim LASTROW As Long
    LASTROW = Cells(Rows.Count, "A").End(xlUp).Row
    Range("B5").Select
    ActiveCell.FormulaR1C1 = _
        "=XLOOKUP(RC[-1],EEB!C[12],EEB!C[8],""Not Found"",0,1)"
    Range("B5:B" & LASTROW).FillDown

Data always starts at row 5, but it is possible for the data to vary from nothing (completely blank) to hundreds+ lines of data.

Thanks!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,883
Office Version
  1. 365
Platform
  1. Windows
How about
VBA Code:
Application.ScreenUpdating = False
    Dim LASTROW As Long
    LASTROW = Cells(Rows.Count, "A").End(xlUp).Row
    Range("B5").FormulaR1C1 = _
        "=XLOOKUP(RC[-1],EEB!C[12],EEB!C[8],""Not Found"",0,1)"
    If LASTROW > 5 Then
      Range("B5:B" & LASTROW).FillDown
    End If
 
Solution

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,883
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Watch MrExcel Video

Forum statistics

Threads
1,130,170
Messages
5,640,574
Members
417,151
Latest member
ChickenTenderer

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