>即時新聞-熱門

2011年2月25日星期五

EXCEL VBA 資料驗證不限筆數

Sub 驗證()


Dim row_s, row_e, col_s, col_e



row_s = ActiveCell.Row

row_e = ActiveCell.SpecialCells(xlLastCell).Row

col_s = ActiveCell.Column

col_e = ActiveCell.SpecialCells(xlLastCell).Column



For i = 0 To row_e - row_s - 1



For j = 0 To col_e - col_s





If ActiveCell.Value > 0 And ActiveCell.Value < 100 Then

Else

錯誤

End If

ActiveCell.Offset(0, 1).Select

Next



ActiveCell.Offset(0, -j).Select





ActiveCell.Offset(1, 0).Select

Next

End Sub

Sub 錯誤()



Selection.Borders(xlDiagonalDown).LineStyle = xlNone

Selection.Borders(xlDiagonalUp).LineStyle = xlNone

With Selection.Borders(xlEdgeLeft)

.LineStyle = xlContinuous

.Weight = xlThick

.ColorIndex = 3

End With

With Selection.Borders(xlEdgeTop)

.LineStyle = xlContinuous

.Weight = xlThick

.ColorIndex = 3

End With

With Selection.Borders(xlEdgeBottom)

.LineStyle = xlContinuous

.Weight = xlThick

.ColorIndex = 3

End With

With Selection.Borders(xlEdgeRight)

.LineStyle = xlContinuous

.Weight = xlThick

.ColorIndex = 3

End With

End Sub

Sub hjju()

'

' hjju Macro

' Teacher 在 2011/2/26 錄製的巨集

'



'

Range("C3").Select

Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

End Sub

0 评论:

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱