If Range is Empty, Unknown number of rows

nniedzielski

Well-known Member
Joined
Jan 8, 2016
Messages
598
Office Version
  1. 2019
Platform
  1. Windows
I am trying to set up some code to detect if a range of rows is empty, and I will not know the number of rows before hand. This is what I am trying, but it doesnt seem to be working (even if the range is empty, the code doesnt run the next line, it goes to end if)

Code:
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
        
        If IsEmpty(Range("d12:d" & finalrow)) = True Then
            Cells(finalrow + 1, 5) = "No Open Copies"
        Else
            'do nothing
        End If

how can i alter this to work?
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Untested...

Code:
Sub x()
Dim finalrow As Long
finalrow = Cells(Rows.Count, 1).End(xlUp).Row
        
        If WorksheetFunction.CountA(Range(Cells(12, 4), Cells(finalrow, 4))) = 0 Then
            Cells(finalrow + 1, 5) = "No Open Copies"
        Else
            'do nothing
        End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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