A
A
Alexander2019-10-02 13:48:37
Visual Basic
Alexander, 2019-10-02 13:48:37

How to find last empty cell MS Excel VBA inline method?

I want to hide cells where the formula outputs an empty string.
I tried this (and a couple of other Excel methods)

Dim Row
Row = Sheet1.Range(Cells(8, 2), Cells(500, 2)).Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
Sheet1.Range(Cells(Row, 2), Cells(500, 2)).EntireRow.Hidden = True

They return 500 because there are formulas that gave me an empty string
. I know that it is possible to sort through For + If (as I will do if there are no alternatives):
Dim Row
For i=500 To 8 Step -1
    If Sheet1.Cells(i,2)<>"" Then
        Row = i
        Exit For
    End If
Next i
Sheet1.Range(Cells(Row, 2), Cells(500, 2)).EntireRow.Hidden = True

I'm looking for some kind of built-in method that works with calculated values ​​when searching for empty cells.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
idShura, 2019-10-02
@NeiroNx

For example, this is how you can:
Range.AutoFilter method

A
akelsey, 2019-10-02
@akelsey

When I wrote macros in VBA more or less professionally, I used macro recording,
pressed a key combination, as I think I pressed Alt + End, I got this code:
I hope it helps.
PS
You can google xlLastCell VBA Excel and probably find a bunch of more suitable examples.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question