Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Apply bottom border only on filled cells, leaves blank cells without border?

I need to apply a bottom border to only filled cells. Archives didn't
yield anything pertinent that I could find but I was able to figure
which line style by recording the keystrokes. I need the hairline
style on the bottom edge, if this is any help:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone

Thanks so much. :oD

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Apply bottom border only on filled cells, leaves blank cells without border?

Hi StargateFan,

try this:
Sub Test4000()
Dim oCll As Range
For Each oCll In ActiveSheet.UsedRange
If oCll.Value < "" Then
oCll.Borders(xlEdgeBottom).LineStyle = xlContinuous
oCll.Borders(xlEdgeBottom).Weight = xlMedium
oCll.Borders(xlEdgeBottom).ColorIndex = 3
End If
Next
End Sub


--
Greetings from Bavaria, Germany

Helmut Weber
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 171
Default Apply bottom border only on filled cells, leaves blank cells without border?

On Sat, 07 Apr 2007 22:45:28 -0400, StargateFan
wrote:

I need to apply a bottom border to only filled cells. Archives didn't
yield anything pertinent that I could find but I was able to figure
which line style by recording the keystrokes. I need the hairline
style on the bottom edge, if this is any help:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone

Thanks so much. :oD


On Sun, 08 Apr 2007 10:44:18 +0200, Helmut Weber
wrote:

Hi StargateFan,

try this:
Sub Test4000()
Dim oCll As Range
For Each oCll In ActiveSheet.UsedRange
If oCll.Value < "" Then
oCll.Borders(xlEdgeBottom).LineStyle = xlContinuous
oCll.Borders(xlEdgeBottom).Weight = xlMedium
oCll.Borders(xlEdgeBottom).ColorIndex = 3
End If
Next
End Sub


--
Greetings from Bavaria, Germany


Greetings, Bavaria! <g

This is cool. It almost works. I realized that a colour should be
defined as well as adding the above hairline code in for the weight so
it now reads like this:

Sub zPutBottomBorderOnSelectedCellsThatHaveTEXT()
Dim oCll As Range
For Each oCll In ActiveSheet.UsedRange
If oCll.Value < "" Then
oCll.Borders(xlEdgeBottom).LineStyle = xlContinuous
oCll.Borders(xlEdgeBottom).Weight = xlHairline
oCll.Borders(xlEdgeBottom).ColorIndex = 1
End If
Next
End Sub

However, a couple of things hopefully can be finetuned. Instead of
putting a border just on the cells that have text in the selected
area, it puts a border on everything on the rows of the selected cells
which defeats the purpose <g.

Also, there are very small columns separating the larger columns that
can contain text. This is in an effort to have a gap between the
individual letters so that wherever a letter should go, it's
represented by this empty long dash for each done by the bottom
border. Once the borders are put in, I will just delete the letters
themselves. This is so that the user knows how many letters are
supposed to be in the answer. Since the above seems to be putting a
border under even these separator cells with no text, the result is
one long line instead of "dashes".

Can this be fixed so that the macro _only_ underlines non-empty cells
in a selection of cells rather than all the rows in the selection?

Thanks. It's a great beginning. :oD

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Apply bottom border only on filled cells, leaves blank cellswithout border?

You could also use conditional formatting to apply the border:
Select the cells, and choose FormatConditional Formatting
From the first dropdown, choose Formula Is
In the formula box, type a formula that refers to the active cell (you
can see its address in the Name box, to the left of the Formula Bar):
=A1<""
Click Format, and on the Borders tab select a colour for the border, and
click the bottom border in the diagram.

StargateFan wrote:
I need to apply a bottom border to only filled cells. Archives didn't
yield anything pertinent that I could find but I was able to figure
which line style by recording the keystrokes. I need the hairline
style on the bottom edge, if this is any help:

Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlHairline
.ColorIndex = xlAutomatic
End With
Selection.Borders(xlEdgeRight).LineStyle = xlNone

Thanks so much. :oD



--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 163
Default Apply bottom border only on filled cells, leaves blank cells without border?

Hi StargateFan,

are you speaking of text as opposed to digits
and just characters other than a-z and A-Z?

Then, if UCase(cell.value) < LCase(cell.value)
there is at least one letter in it.

Instead of putting a border just on the cells
that have text in the selected
area, it puts a border on everything
on the rows of the selected cells
which defeats the purpose <g.


Hmm...

See also: http://tinyurl.com/2jbleh
for empty vs null vs ""

Sub Test4000B()
Dim oCll As Range
For Each oCll In ActiveSheet.UsedRange
If Not LCase(oCll.Value) = UCase(oCll.Value) Then
oCll.Borders(xlEdgeBottom).LineStyle = xlContinuous
oCll.Borders(xlEdgeBottom).Weight = xlHairline
oCll.Borders(xlEdgeBottom).ColorIndex = 1
Else
' otherwise remove border, skip this one if you like
oCll.Borders(xlEdgeBottom).LineStyle = xlNone
End If
Next
End Sub

--
Greetings from Bavaria, Germany

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Paste-linking cells from Excel leaves a border in PP Jack Charts and Charting in Excel 0 September 22nd 09 07:17 PM
Border at bottom of worksheet Terry Excel Discussion (Misc queries) 3 May 17th 07 08:51 PM
Repeat bottom Border Scafidel Excel Discussion (Misc queries) 3 August 29th 06 05:37 AM
Apply Border Bill Excel Programming 6 July 29th 05 12:15 AM


All times are GMT +1. The time now is 09:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"