수식셀들을 순환하면서 수식에 +나 -가 있는 셀들을 rngSum이라는 가상의 영역 범위에 모았다가..
그 셀의 개수를 메시지박스에 띄워서 몇개가 있는지 표시하면 될 것 같습니다.
Option Explicit
Sub abFindAdjustedFormulaCells() Dim rngSrc As Range Set rngSrc = ActiveSheet.UsedRange On Error Resume Next Set rngSrc = rngSrc.SpecialCells(xlCellTypeFormulas, 23)
If rngSrc Is Nothing Or Err.Number = 1004 Then MsgBox "현재 시트에는 수식셀이 없습니다." Exit Sub ElseIf Err.Number <> 1004 And Err.Number <> 0 Then MsgBox "알수 없는 에러가 발생하여 종료합니다." Exit Sub Else Dim r As Range, rngSum As Range For Each r In rngSrc If InStr(r.Formula, "+") Or InStr(r.Formula, "-") Then If rngSum Is Nothing Then Set rngSum = r Else Set rngSum = Union(rngSum, r) End If End If Next r End If
On Error GoTo 0
Dim msgResult As Long If rngSum Is Nothing Then MsgBox "임의로 조정된 수식이 없습니다." Else msgResult = MsgBox(rngSum.Cells.Count & "개의 수식이 임의로 조정되었습니다." & _ "수정하시겠습니까?", vbYesNo, " 수식 조정 여부 확인창") If msgResult = vbYes Then '### 수식을 수정하는 코드를 넣으세요.. End If End If
고수가되고파님..
아래와 같은 로직을 이용해보세요..
수식셀들을 순환하면서 수식에 +나 -가 있는 셀들을 rngSum이라는 가상의 영역 범위에 모았다가..
그 셀의 개수를 메시지박스에 띄워서 몇개가 있는지 표시하면 될 것 같습니다.
Option Explicit
Sub abFindAdjustedFormulaCells()
Dim rngSrc As Range
Set rngSrc = ActiveSheet.UsedRange
On Error Resume Next
Set rngSrc = rngSrc.SpecialCells(xlCellTypeFormulas, 23)
If rngSrc Is Nothing Or Err.Number = 1004 Then
MsgBox "현재 시트에는 수식셀이 없습니다."
Exit Sub
ElseIf Err.Number <> 1004 And Err.Number <> 0 Then
MsgBox "알수 없는 에러가 발생하여 종료합니다."
Exit Sub
Else
Dim r As Range, rngSum As Range
For Each r In rngSrc
If InStr(r.Formula, "+") Or InStr(r.Formula, "-") Then
If rngSum Is Nothing Then
Set rngSum = r
Else
Set rngSum = Union(rngSum, r)
End If
End If
Next r
End If
On Error GoTo 0
Dim msgResult As Long
If rngSum Is Nothing Then
MsgBox "임의로 조정된 수식이 없습니다."
Else
msgResult = MsgBox(rngSum.Cells.Count & "개의 수식이 임의로 조정되었습니다." & _
"수정하시겠습니까?", vbYesNo, " 수식 조정 여부 확인창")
If msgResult = vbYes Then
'### 수식을 수정하는 코드를 넣으세요..
End If
End If
End Sub