MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 30th, 2004, 03:12 PM   #1
XLML
 
Join Date: Aug 2003
Posts: 400
Default macro to filter cells with borders

Is there a way to use VBA to filter to show only cells with borders? I am specifically working with cells in Column J.

Thanks in advance,
XLML
Using XL2000
XLML is offline   Reply With Quote
Old Mar 30th, 2004, 03:41 PM   #2
DRJ
MrExcel MVP
 
DRJ's Avatar
 
Join Date: Feb 2002
Location: California
Posts: 3,857
Default

Try this:

Code:
Sub test()

Dim x As Long
Dim LastRow As Long

    LastRow = Range("J65536").End(xlUp).Row + 100
    For x = 1 To LastRow
        If Range("J" & x).Borders(xlEdgeLeft).LineStyle = xlContinuous Then
            Else
            Range("J" & x).RowHeight = 0
        End If
    Next x

End Sub
__________________
Excel VBA Training and Certification (Lesson 1 is free)
<hr>

<hr>-Jacob
DRJ is offline   Reply With Quote
Old Mar 30th, 2004, 03:50 PM   #3
onlyadrafter
 
Join Date: Aug 2003
Location: England
Posts: 4,584
Default Re: macro to filter cells with borders

Hello,

Not certain of what you are trying to achieve but is this code any use, it hides rows where the J column cell has a border on the left or the right

Code:
Sub FILTER_BORDERS()
For MY_ROWS = 1 To Range("J65536").End(xlUp).Row
    If Range("J" & MY_ROWS).Borders(xlEdgeLeft).LineStyle > 0 Or _
        Range("J" & MY_ROWS).Borders(xlEdgeRight).LineStyle > 0 Then
        Rows(MY_ROWS).Hidden = True
    End If
Next MY_ROWS
End Sub
Any use?
__________________
-------------------------
Hope this is helpful.
-------------------------
only a drafter,
but broadening my Excel knowledge.
onlyadrafter is offline   Reply With Quote
Old Mar 30th, 2004, 04:46 PM   #4
XLML
 
Join Date: Aug 2003
Posts: 400
Default Re: macro to filter cells with borders

Thanks for the replies. Olnyadrafter - I want to show only rows with borders. DRJ - I am using your macro which works great but I was trying to use dropdown arrows. Is there a way to do this with the dropdown arrows so that I can hide/unhide?

XLML
XLML is offline   Reply With Quote
Old Mar 30th, 2004, 04:48 PM   #5
DRJ
MrExcel MVP
 
DRJ's Avatar
 
Join Date: Feb 2002
Location: California
Posts: 3,857
Default

You mean likt the auto filter arrows? I don't think so. You can make a couple buttons and attach macros to hide and unhide the cells.
__________________
Excel VBA Training and Certification (Lesson 1 is free)
<hr>

<hr>-Jacob
DRJ is offline   Reply With Quote
Old Mar 30th, 2004, 04:51 PM   #6
onlyadrafter
 
Join Date: Aug 2003
Location: England
Posts: 4,584
Default Re: macro to filter cells with borders

Hello,

XLML

This is the code to show rows with borders on the left or right in Column J, not sure what you mean by the down arrow.

Code:
Sub FILTER_BORDERS()
For MY_ROWS = 1 To Range("J65536").End(xlUp).Row
    If Range("J" & MY_ROWS).Borders(xlEdgeLeft).LineStyle < 0 And _
        Range("J" & MY_ROWS).Borders(xlEdgeRight).LineStyle < 0 Then
        Rows(MY_ROWS).Hidden = True
    End If
Next MY_ROWS
End Sub
__________________
-------------------------
Hope this is helpful.
-------------------------
only a drafter,
but broadening my Excel knowledge.
onlyadrafter is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 08:51 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2009 by MrExcel Consulting.