Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #20  
Old 06-18-2014, 10:13 AM
charlesdh charlesdh is offline NEWB to Macros - formatting exports Windows 7 32bit NEWB to Macros - formatting exports Office 2010 32bit
Expert
 
Join Date: Apr 2014
Location: Mississippi
Posts: 382
charlesdh is on a distinguished road
Default

Hi,

Here is 2 more methods to get the "Last" row.
(Not sure if Bob mentioned this)
The first one uses a excel function for "Special Cells
The second will look from the bottom of the column to the first row with data.

Hope these help you..


Code:
Sub xlCellTypeLastCell_Example_Row()
    Dim LastRow As Long
    With ActiveSheet
        LastRow = .Range("A1").SpecialCells(xlCellTypeLastCell).Row
    End With
    MsgBox LastRow
End Sub
Code:
Sub Last_Row()
''' This is different from other example
''' We'll use the XlUp format'''
''' This looks from the bottom up ''
Dim LastRow As Long
    With ActiveSheet
        LastRow = .Range("A65536").End(xlUp).Row
    End With
    MsgBox LastRow
End Sub
I use the second code often. If you want to know the "Last" unused row in a column you can add +1 after the row.
You can use this if you need to add data to the column.
Code:
 LastUnusedRow = .Range("A65536").End(xlUp).Row+1
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting contents after Tab of continuous lines or formatting specific area of word pawii Word 1 05-12-2014 05:24 AM
macros stebrownsword Word VBA 0 08-28-2013 01:16 AM
NEWB to Macros - formatting exports How to do Formatting Using Macros anju16saini Word VBA 1 03-11-2013 04:15 AM
NEWB to Macros - formatting exports Formatting with macros WaltR Word VBA 8 05-15-2012 06:28 PM
Macros nore Outlook 0 06-01-2011 04:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:14 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft