use border for IF test

S

Steve

Ok, apparently my previous post was too involved so let's try this.

I want to perform a task using an IF test.
The most common element in the workbook that I can think of to test for is
the existence of a border around a group of cells.

So far, my tests seem to not be fully working, and I can't see why.

Sub borderloopA()
Dim rcell, rcell1, rcell2 As Range
Dim lx As Integer

Set rcell = Selection
Set rcell1 = Selection
Set rcell2 = Selection
'Application.DisplayAlerts = False

For Each rcell In Selection
Do
For Each rcell1 In Selection
Do
'if borderTOP = true then
If rcell1.Borders(xlEdgeTop).LineStyle = xlSolid Then 'Or
xlDouble
ActiveCell.Offset(1, 0).Select
'rcell.Select
'if border-TOP/BOTTOM = false then
If ActiveCell.Borders(xlEdgeTop).LineStyle <> xlSolid Then
ActiveCell.Offset(1, 0).Select
'rcell1.Select
'if border-TOP/BOTTOM = false then
If ActiveCell.Borders(xlEdgeTop).LineStyle <>
xlSolid Then
ActiveCell.Offset(1, 0).Select
'rcell1.Select
'if borderBottom = true then
For Each rcell2 In Selection
If
rcell2.Borders(xlEdgeBottom).LineStyle = xlSolid Then
ActiveSheet.Range(rcell1,
rcell2).Select
With Selection
.Merge
.VerticalAlignment = xlCenter
.HorizontalAlignment =
xlCenter
End With
Set rcell1 = Nothing
Set rcell2 = Nothing
'end if
End If
Next rcell2
'end if
End If
'end if
End If
'end if
End If
lx = lx + 1
Loop Until lx = 2
Next rcell1
Loop Until ActiveCell.Style.IncludeBorder = False
Next rcell

'Application.DisplayAlerts = True


End Sub
 
S

Steve

ok, scratch this, the border test works fine, it's something else that's not
working-- will use a new post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

merge rows based on criteria 1
cell selection, merging..... 1
merge cells 6
looping macro to test for borders 9
Swap 2 ranges 3
Border formatting row of cells 22
using border/usedrange in vba 0
VBA Export to PDF 0

Top