excel vba last column in range

'VBA to get the last row in column A that has a value.

'Change `A` to the column you care about:
With Sheet1
    LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With


'A shorter way:
LastRow = Sheet1.[A1048576].End(xlUp).Row


'And to get the row of the last cell with a value
'just above the FIRST blank cell VERTICALLY:
LastRow = Sheet1.[A1].End(xlDown).Row

'----------------------------------------------------------


'The most reliable way to get the last row with data 
'for the entire sheet is to use the following function: 

LastRow = LastUsedRow(Sheet1.[A1])

Function LastUsedRow(r As Range)
    On Error Resume Next
    r.Parent.AutoFilterMode = False
    With r.Cells.Find("*", r, xlFormulas, , , xlPrevious)
        LastUsedRow = 1
        LastUsedRow = .Row
    End With
End Function

3.89
9
AYOMI 90 points

                                    Dim rRange As Range
Dim rDuplicate As Range

Set rRange = ActiveSheet.UsedRange
lFirstRow = rRange.Row
lLastRow = rRange.Rows.Count + rRange.Row - 1
lFirstColumn = rRange.Column
lLastColumn = rRange.Columns.Count + rRange.Column - 1
' New reference to current range (can be truncated)
Set rDuplicate = Range(Cells(lFirstRow, lFirstColumn), _
      Cells(lLastRow, lLastColumn))

3.89 (9 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
find last row in excel using macro how to get the last row number in a selection vba find last row in table vba vba find last column in row looking for the last row vba excel select last column used vba excel last row vba excel vba find row number for last entry excel vba last row in range get last row of a sheet vba vba get last column select last row used in excel using vba get last column in excel vba last filled row in excel vba vba find last row in range vba find last row in a range get last date from column excel vba excel vba find last cell with value how to get last use row in excel vba find last row excel vba vba get last row of column find last row in named range vba find lastrow in excel vba last row and column in excel vba find last row for each column with data in vba find last row with data in vba get lastrow excel vba find lastrow excel vba Select frist and last row of a column vba find last filled row in excel VBA find the last filled row in excel vba find last row with row in vba last row with data in excel vba excel vba select last used row in column get last filled row vba vba find last column in row with data vba excel last cell in row excel vba usedrange last row vba get last row column vba excel last row of column how i can know last row in excel by vba how to find last row in specific column in vba excel vba find last row in column with blanks vba find the last row excel get last column vba excel get last row vba excel vba find last filled cell in column vba count last row with data in column excel get last row in column get value from last row excel vba vba get the last cell in column excel get last row with data vba excel vba find last function set range finding last value in cell VIA VBA excel find last used cell in a column with excel vba vba excel last row with value vba find last row in all columns vba find last row in all column vba find last row in any column VBA get last cell in column with data last row by vba vba select the last column in a row vba select the last cell in a row last row in column excel vba excel vba get first and last row of range vba get the first and last column from named range vba get the first and last column from range vba excel last row vba last columne vba excel last cell vba calculate last row vba excel how to find last row with data get last row in a column vba get last row in column vba get last cell with data vba vba excel find last column in row how to get last weekend date in excel in vba vba excel find last row vba get last filled row vba last cell in column vba excell find last cell in column get last row number of a column in excel vba excel vba last used column get last column number vba vba excel listobject get value of last row get the last row in excel vba find last used row and column vba last column vba Vba Get last row with column No excel vba last row vba last row in column vba how to get last row excel vba get last row in table excel vba find last cell in a column excel vba get cell values Range("A1").End(xlDown).Row find the last row in excel vba select last column and range in it with vba select last column and few cells in it with vba select last cell of a column in a table using vba find last column in table vba find rightmost empty cell by row in vba range cell and last filled in excel vba last cell in column vba vba last row with data vba lastrow = excel vba last row in column number excel vba last row with value in column get last row in vba exdel vba get last row vba detect last row of data excel last used column vba select last column in a row vba find last column find last row vba vba find last record range find the last cell with value get last row of specifc cell vba get the last column of a range excel get the last column count vba get the last column of a row get last row vba excel vba determine last row column lastrow from specific row vba find lastrow vba excel vba last column in range count last column in vba count last row in vba vba get the last row Get last line used in Excel vba end(xlup) range columns.count end(xltoleft) vba range columns.count end(xltoleft)vba vba find the last cell in a column last row via cell vba excel vba get the last used row vba get last row of used range how use where to detect last row vba last row of selected cell 5 ways to find last row last cell in excel vba how to find the end of a column in excel vba excel vba find last used cell in column excel vba find last cell lCol in vba DO MACRO RECORDER SHOW LAST ROW slect last row vba last filled cell vba vba find the last column with data how to get last row number of excel in vba how to get last row of excel in vba LastUsedRow vba VBa get last row of pasted range define last row vba find last used row in column excel vba vba last row of column last column in excel VBA vba get last row in column find last row in excel vba getting the last row in excel vba how to get the last row number in excel vba last row excel vba get last row lastCol vba excel vba find used cell with value lastline vba excel vba get last row in range excel macro get last column Cells(1, Column.count).End(xlLeft).Row lastcol = .cells(1 .columns.count).end(xltoleft).column vba get end row vba get last used row in column last line excel vba code how to find the last row with data in excel vba start counting fin the last row c# excel vba move to last cell in column that is not "" 5 ways to get last row vba code to find last filled row how to check the last row in excel vba some last row vba .ecnd(xlUP).Row lastrow range vba last row function vba get last column vba vba code for finding last row find last used row in column vba excel vba last row 5 way how to get column count in excel vba how to end of column count in excel vba excel lastrow lastcol 5 way excel vba lastrow excel vba to go to last row how to find end of range excel vba get last written cell vba get final column with data in it how to find last rows count to last row vba excel vba - find last row vba last column 5 way find last row in either of two columns excel vba excel endrow last column vba way vba excel last row in range vba excel last row used excel vba last used row last row vba excel select last written line in excel vba find last data row in excel vba excel rows count vba vba code to find last row vba why is last row showing 1 excel vba last column vba get last row excel vba get las row get last filled column excel vba last columns vba vba last column number vba last row number excel vba find last row in column with data excel vba return last column with data retrieve the last row number from a range vba last row select vba vba last row with values vba last column vba get last row with data end of row vba excel vba find get last rowin column using excel macro to calculate the last row vba find last row find last cell in exce vba vba lastrlw vba get last row with value last row number in excel vba vba get lastrow lastrow vba how to find the index of the last column in excel vba lastrow vba find end of range get last row in excel vba last row vba vba find last row with data excel vba get last row with data vba last rows find last column in excel vba lastrow = cells(rows.count 1).end(xlup).row get last columns excel macro find last row last row in vba vba lastrow vba find the last cell with data last active row vba how to select last row with data in excel VBA last row in excel vba identifying last row in excel vba get lastrow vba vba last row last column vba excel vba excel get last row excel vba find last row excel vba get last row excel vba find last row in column excel vba get last row in column excel vba find get last row in column
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source