|
* 답변하시는 분들께 도움이 되도록 자신의 환경을 아래 항목 옆에 기재해 주세요.
- 엑셀 버전(95,97,2000,xp,2003,2007): 2010
* 아래줄에 질문을 작성하세요 >>
이 파일 올릴려고 하니 오류가 나서 직접 VBA만 올립니다.
123248번에 오류 메시지를 올려 놓았습니다.
VBA로 잠금셀에 붙여넣기 하려고 하니까 오류가 나는데 어떻게 해야 하는지요?
Sub 통합_Click()
Dim oWorkbook As Workbook, curCell As String
Set oWorkbook = Application.ActiveWorkbook
With Application
.ScreenUpdating = False
curCell = ActiveCell.Address(, , , True)
Dim ws As Worksheet
Dim idxa As Integer
Dim goods() As String
Dim size() As String
Dim gCnt As Integer
Dim rRow As Integer
Dim cCol As Integer
Dim tCnt As Integer
Set ws = Sheets("통합")
Sheets("통합").Range("G4").Value = Format(Now(), "yyyy년 MM월 DD일 ")
tCnt = 6
idxa = 0
Sheets("통합").Select
Sheets("통합").Range("K5").Select
Sheets("통합").Activate
Do
idxa = idxa + 1
Loop While Sheets("통합").Range("K" & idxa + 4).Value <> ""
gCnt = idxa - 1
ReDim goods(gCnt)
ReDim size(gCnt)
For idxa = 1 To gCnt
goods(idxa) = Sheets("통합").Range("K" & idxa + 4).Value
size(idxa) = Sheets("통합").Range("L" & idxa + 4).Value
Next
ws.Unprotect
For idxa = 1 To gCnt
With ws
.Activate
Sheets(goods(idxa)).Select
Range("B6").Select
If Range("B7").Value <> "" Then
Selection.End(xlDown).Select
End If
rRow = Selection.Row
cCol = Selection.Column
Range("G" & rRow & ":J" & rRow).Select
Selection.Copy
Sheets("통합").Select
Range("B" & tCnt).Value = goods(idxa)
Range("C" & tCnt).Value = size(idxa)
Range("D" & tCnt).Select
ActiveSheet.Unprotect "1225"
' 이 부분은 Dim 바로 밑에 두어도 보고 한 칸 위에도 두어 보았습니다.
Selection.PasteSpecial Paste:=xlPasteValues
tCnt = tCnt + 1
End With
Next
.Goto Range(curCell)
.ScreenUpdating = True
End With
ActiveSheet.Protect "1225"
End Sub
그리고 Sheet에는
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
On Error Resume Next
Sheets(Target.Value).Activate
End Sub
Private Sub Worksheet_Activate()
'ActiveSheet.Unprotect Password:="1225"
Cells.Locked = False '전체셀 잠금 해제
Range("G6:J1000").Locked = True '보호하려는 특정범위 잠금
ActiveSheet.Protect Password:="1225", userinterfaceonly:=False
End Sub
이런식으로 했습니다.
또 이 문서를 열 때나, 저장 시에 오랜 시간이 걸립니다. 왜 그런 것인지요?
해결 방법은 무엇인지요? 알려 주시면 감사하겠습니다. |
|