本文介绍了关于创建代码,为excel表中的空行设置粗体边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

dears,

好问候

我正在搜索一个代码在excel表中为每个空行设置边框

i'm searching for one code to make borders around each unempty rows in excel sheet

我如何在vba代码中创建它,

how can i made it within vba code,

问候........ ......... 

regards................. 

推荐答案

我认为关键是如何确认行是空行。

I think the key point is how to confirm the row is unempty row.

我建议你比较行的整个单元格计数空白单元格数。如果它们是相同的值,则该行是空行。

I would suggest you compare the row's whole cells count the blank cells count. If they are same value, the row is an empty row.

一旦你打电话告诉这是一个空/空行,那么你可以设置它的边界。

Once you call tell this is an empty/unempty row, then you could set its border.

这是简单的代码。

Sub Test()
Dim WS As Worksheet
Set WS = ActiveSheet
Dim rowRng As Range
For Each rowRng In WS.UsedRange.Rows
If rowRng.SpecialCells(xlCellTypeBlanks).Cells.Count <> rowRng.Cells.Count Then
With rowRng
.Borders.Weight = xlThick
.Borders(xlInsideVertical).LineStyle = xlNone
.Borders(xlInsideHorizontal).LineStyle = xlNone
End With
End If
Next rowRng
End Sub

最好的问候,

特里


这篇关于关于创建代码,为excel表中的空行设置粗体边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 03:31