PIECE OF CAKE - MS Excel - Finding Last Row


Aprenda várias maneiras de detectar qual é a última linha com dados dentro de uma planilha.

Function FindingLastRow(nName As String, nColumnAnalyse As String) As Long
    ' © 2007-20 Alefe & Bete Processamento de Dados LTDA - ME, except where noted, all rights reserved.
    '      Author: André Bernardes
    '     Contact: andreluizbernardess@gmail.com | https://goo.gl/EUMbSe/
    ' Application: AutoGenClosing®
    ' Description: Different ways to find the last row number of a range
    ' SOURCE: TheSpreadsheetGuru.com

    Dim sht As Worksheet
    Dim LastRow As Long

    Set sht = ThisWorkbook.Worksheets(nName)

    ' Ctrl + Shift + End
    'Let LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row

    ' Using UsedRange
    'sht.UsedRange 'Refresh UsedRange
    'Let LastRow = sht.UsedRange.Rows(sht.UsedRange.Rows.Count).Row

    'Using Table Range
    'Let LastRow = sht.ListObjects("Table1").Range.Rows.Count

    'Using Named Range
    'Let LastRow = sht.Range("MyNamedRange").Rows.Count

    'Ctrl + Shift + Down (Range should be first cell in data set)
    'Let LastRow = sht.Range("D1").CurrentRegion.Rows.Count
    
    ' Retorna a última Linha da principal coluna.
    Let LastRow = Sheets(nName).Range(nColumnAnalyse & Rows.Count).End(xlUp).Row

    Let FindingLastRow = LastRow
End Function

#A&A #PIECEOFCAKE #POC #VBA #Excel #MSExcel #Row #LastRow
Consulte-nos
⬛◼◾▪ Social Media ▪◾◼⬛
• FACEBOOK • TWITTER • INSTAGRAM • TUMBLR • GOOGLE+ • LINKEDIN • PINTEREST

⬛◼◾▪ Blogs ▪◾◼⬛ 


⬛◼◾▪ CONTATO ▪

Nenhum comentário:

Postar um comentário

diHITT - Notícias