![]() |
use border for IF test
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 |
scratch request
ok, scratch this, the border test works fine, it's something else that's not
working-- will use a new post. "Steve" wrote: 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 |
All times are GMT +1. The time now is 10:05 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com