VBA Error with .FillDown

sax2play

Board Regular
Joined
Mar 13, 2021
Messages
63
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

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:
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
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

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