Does anyone know how to make this in excel?
An IF function that draws a line through a cell based on a certain value?
http://euler.slu.edu/escher/upload/t...px-Random2.jpg
Does anyone know how to make this in excel?
An IF function that draws a line through a cell based on a certain value?
http://euler.slu.edu/escher/upload/t...px-Random2.jpg
an IF formula can only return a value based on a condition; it cannot return a format.
With conditional formatting you can return all other forms of cells borders, but not diagonal borders.
However, this can be achieved with VBA. Check this link.
HTH!
Hi thanks a lot.
I have one more question.
I tried to adjust the code so it creates a line down if it is a 1 and up if it is a 0.
Sometimes it works, and sometimes it makes an X.
How would you fix this?
Untitled.jpg
---
Private Sub Worksheet_Change(ByVal Target As Range)
Dim c As Variant
Dim addr As String
Set Target = Range("A1:C20")
If Intersect(Target, ActiveCell) Is Nothing Then Exit Sub
For Each c In Target
If c = 0 And Len(c) <> 0 Then
addr = c.Address
With Range(addr).Borders(xlDiagonalUp)
.LineStyle = xlContinuous
End With
ElseIf c = 1 And Len(c) <> 0 Then
addr = c.Address
With Range(addr).Borders(xlDiagonalDown)
.LineStyle = xlContinuous
End With
End If
Next
End Sub
this should do it:
![]()
Please Login or Register to view this content.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks