엑셀 매크로 VBA 10. 나의 함수 : 여러셀 가로줄,세로줄선택기 소스코드
엑셀 매크로 VBA 10. 나의 함수 : 여러셀 가로줄,세로줄선택기 소스코드
셀을 선택후 반복해서 가로줄 / 세로줄을 선택한다.
Sub 여러가로줄선택기()
Dim a
Dim sela1 As Range
Dim sela2 As Range
Dim sela3 As Range
Dim cnts As String
Dim cnt As Long
Dim incx As Long
Dim incy As Long
Dim i As Long
Dim j As Long
On Error GoTo errhandler
Set sela2 = Application.InputBox(Type:=8, prompt:="기준 셀을 선택하세요 ?", Title:="틀반복복사기")
basex = CLng(sela2.Column)
basey = CLng(sela2.row)
Set sela3 = Application.InputBox(Type:=8, prompt:="이동 셀을 선택하세요 ?", Title:="틀반복복사기")
refx = CLng(sela3.Column)
refy = CLng(sela3.row)
incx = refx - basex
incy = refy - basey
cnts = InputBox("반복회수를 입력하세요 ?", "틀반복복사기")
cnt = CLng(cnts)
Dim tArea As String
Dim tArea2 As String
Dim strRC As String
For idx = 0 To cnt - 1
a = Trim(Str(basey + incy * idx)) & ":" & Trim(Str(basey + incy * idx))
Range(a).Select
If Not idx = cnt Then
strRC = "R" & Trim(Str(basey + incy * idx)) & ":R" & Trim(Str(basey + incy * idx))
tArea = strRC + "," + tArea
tArea2 = a + "," + tArea2
End If
Next
tArea2 = tArea2 + a
tArea = tArea + strRC
Range(tArea2).Select
Dim strName As String
strName = InputBox("영역의 이름은 ?", "이름정의")
ActiveWorkbook.Names.Add Name:=strName, RefersToR1C1:="=" & tArea
Exit Sub
errhandler:
MsgBox "에러가 발생하여 작업을 취소하였습니다"
End Sub
Sub 여러세로줄선택기()
Dim a
Dim sela1 As Range
Dim sela2 As Range
Dim sela3 As Range
Dim cnts As String
Dim cnt As Long
Dim incx As Long
Dim incy As Long
Dim i As Long
Dim j As Long
On Error GoTo errhandler
Set sela2 = Application.InputBox(Type:=8, prompt:="기준 셀을 선택하세요 ?", Title:="틀반복복사기")
basex = CLng(sela2.Column)
basey = CLng(sela2.row)
Set sela3 = Application.InputBox(Type:=8, prompt:="이동 셀을 선택하세요 ?", Title:="틀반복복사기")
refx = CLng(sela3.Column)
refy = CLng(sela3.row)
incx = refx - basex
incy = refy - basey
cnts = InputBox("반복회수를 입력하세요 ?", "틀반복복사기")
cnt = CLng(cnts)
Dim tArea As String
Dim tArea2 As String
Dim strRC As String
For idx = 0 To cnt - 1
a = Chr(65 + basex + incx * idx - 1) & ":" & Chr(65 + basex + incx * idx - 1)
Range(a).Select
If Not idx = cnt Then
strRC = "C" & Trim(Str(basex + incx * idx)) & ":C" & Trim(Str(basex + incx * idx))
tArea = strRC + "," + tArea
tArea2 = a + "," + tArea2
End If
Next
tArea2 = tArea2 + a
tArea = tArea + strRC
Range(tArea2).Select
Dim strName As String
strName = InputBox("영역의 이름은 ?", "이름정의")
ActiveWorkbook.Names.Add Name:=strName, RefersToR1C1:="=" & tArea
Exit Sub
errhandler:
MsgBox "에러가 발생하여 작업을 취소하였습니다"
End Sub
.