Results 1 to 2 of 2

Need a way to search a whole workbook and return the lowest row that contains data

Threaded View

LFDallas Need a way to search a whole... 11-14-2011, 02:21 PM
LFDallas Re: Need a way to search a... 11-14-2011, 05:26 PM
  1. #1
    Registered User
    Join Date
    11-14-2011
    Location
    Albuquerque, New mexico
    MS-Off Ver
    Excel 2010
    Posts
    2

    Angry Need a way to search a whole workbook and return the lowest row that contains data

    I'm looking for a way to search every worksheet and then return the lowest row that contains data in a Message Box. What I have so far is...

    Sub lowestRow()
    
    Dim currentLowestRow As Integer
    Dim lowestRow As Integer
    Dim nullMsgBox As Integer
    nullMsgBox = 0
    currentLowestRow = 0
    lowestRow = 0
    
    Dim ws As Worksheet
    For Each ws In ThisWorkbook.Worksheets
        ws.Activate
        'This is where i would search every cell
        'set currentLowestRow to the lowest row on this sheet
        'compare currentLowestRow with lowestRow and if 
        'currentLowestRow is greater set its value to lowestRow    
    Next ws
    Sheets(1).Activate
    
    nullMsgBox = MsgBox("Your Last Row of Data is " & lowestRow, vbOKOnly)
    
    End Sub
    There are some instances where the first row(s) on a given worksheet may not contain data. The workbooks also have anywhere from 7-50 sheets. Your help is greatly appreciated.
    Last edited by LFDallas; 11-14-2011 at 05:25 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1