Set rng = Range(myfind.Offset(1, 0), myfind.Offset(1, 2))
With rng.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With rng.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With rng.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With rng.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
uj5u.com熱心網友回復:
也不說干啥,就說要簡化這代碼不簡化有啥問題嗎?
無非就是吧 xlEdgeLeft xlEdgeBottom xlEdgeRight xlInsideVertical 這幾個常數抓出來看具體的值是多少,組成數列然后看有沒有辦法寫出數列通式,然后用回圈搞定咯
uj5u.com熱心網友回復:
吶,4個常數分別是 7,9,10,11那么就
Set rng = Range(myfind.Offset(1, 0), myfind.Offset(1, 2))
dim i as long
for i = 7 to 11
if i <> 8 then
With rng.Borders(i)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
end if
next
沒測驗哈,自己試試看行不行
uj5u.com熱心網友回復:
相同部分做一個整體,寫個頭。需要的時候,做一個呼叫uj5u.com熱心網友回復:
我用rng.
.borders
.linestyle
.borders
.linestyle
這樣寫說錯了
uj5u.com熱心網友回復:
你那樣寫的,當然錯了。
With Rng.Borders
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
uj5u.com熱心網友回復:
用程序,可以簡化:
Set rng = Range(myfind.Offset(1, 0), myfind.Offset(1, 2))
setborder rng, xlEdgeLeft
setborder rng, xlEdgeBottom
setborder rng, xlEdgeRight
setborder rng, xlInsideVertical
sub setborder(rng, pos)
With rng.Borders(pos)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
end sub
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/33345.html
標籤:VBA
