Excel & VBA---Brain Training
실수로 화일을 망쳐서 다시 올린다..
아래 구문을 실행하면 몇장의 시트에 테이블이 만들어지고
테이블에는 수식이 있는 셀이 있고
색상이 칠해진 셀들이 있다
Sub createQuestionFile()
Dim oBook As Workbook, shtX As Worksheet, rDatas As Range
Dim rRow As Range, iLastCol As Integer
Set oBook = Workbooks.Add
For Each shtX In oBook.Worksheets
Set rDatas = shtX.Cells(Int(Rnd() * 5) + 2, _
Int(Rnd() * 5 + 2)).Resize(Int(Rnd() * 10) + 2, _
Int(Rnd() * 5) + 5)
iLastCol = rDatas.Columns.Count
With rDatas.Resize(, rDatas.Columns.Count - 1)
.Formula = "=INT(RAND()*100)+1"
.Value = .Value
End With
For Each rRow In rDatas.Rows
rRow.Cells(iLastCol) = "=SUM(" & _
rRow.Cells(1).Address & ":" & _
rRow.Cells(iLastCol - 1).Address & ")"
Next
With rDatas
.Font.Name = "맑은 고딕"
.Font.Size = 10
With rDatas.Rows(Int(Rnd() * rDatas.Rows.Count) + 1)
.Interior.ColorIndex = 3
.Font.ColorIndex = 2
End With
End With
Next
End Sub
아래의 그림과 같이 만들어진다

이것을 색상이 있는 색은 색상을 없애고
숫자도 모두 없애고
수식이 있는 셀은 수식을 없애고 값만 남겨서 새로운 통합문서로
옮겨달라는 문제!!
Braintraining_049.