+ Reply to Thread
Results 1 to 6 of 6

selecting visible rows

Hybrid View

  1. #1
    Spammer
    Join Date
    02-12-2007
    Posts
    22
    Quote Originally Posted by mikerickson
    Do you mean visible as in "not hidden" or visible as in "within the current scroll area"?

    If the former, you could use
    ActiveSheet.UsedRange.SpecialCells(xlCellTypeVisible)



    hi i mean within the current scroll area.
    and i am sorry but i dont understand your reply as it is above my head , can you explain your solution a bit more simpler for me to understand please as i am a newbie to this

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    The VB code
    ActiveWindow.VisibleRange.SpecialCells(xlCellTypeVisible)
    will return the range of cells that is currently visible in the window. The .SpecialCells is to eliminate those rows that would be in the window, but have been hidden.
    This macro
    Sub SelectWindow()
        ActiveWindow.VisibleRange.SpecialCells(xlCellTypeVisible).Select
    End Sub
    will select that.
    This macro will copy the values (equivilant to Copy/PasteSpecialValues) in that range to the same range on "sheet2"
    Sub copyWindowValues()
        Dim xRay As Range
        Set xRay = ActiveWindow.VisibleRange.SpecialCells(xlCellTypeVisible)
        xRay.Parent.Parent.Sheets("sheet2").Range(xRay.Address).Value = xRay.Value
    End Sub
    This one copies formulas (equivilant to Copy/Paste)
    Sub copyWindowToTwo()
        Dim xRay As Range
        Set xRay = ActiveWindow.VisibleRange.SpecialCells(xlCellTypeVisible)
        xRay.Parent.Parent.Sheets("sheet2").Range(xRay.Address).Formula = xRay.Formula
    End Sub

  3. #3
    Spammer
    Join Date
    02-12-2007
    Posts
    22
    i can see how the codes work but i just want it to select rows with data in and not if they contain blank rows

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    Add this line of code.
    Set xray = Application.Union(xray.SpecialCells(xlCellTypeFormulas), xray.SpecialCells(xlCellTypeConstants))

+ Reply to Thread

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