Excel Vba) 셀의 행, 열(column, row) 주소 알아내기 또는 삽입하기 더불어 제어하기
셀주소 - 행, 열 주소알아내기 또는 선택하기
Sub Macro1()
'ActiveCell.EntireColumn.Select
'ActiveCell.EntireRow.Select
a = ActiveCell.Address
b = ActiveCell.EntireColumn.Address
c = ActiveCell.EntireRow.Address
MsgBox a & b & c
End Sub
셀 삽입 - 행, 열 삽입
'Insert row above active cell
ActiveCell.EntireRow.Insert
'Insert row below active cell
ActiveCell.Offset(1).EntireRow.Insert
'Insert column to the left of the active cell
ActiveCell.EntireColumn.Insert
'Insert column to the right of the active cell
ActiveCell.EntireColumn.Offset(0, 1).Insert
End Sub
Select active column / row
ActiveCell.EntireColumn.Select
ActiveCell.EntireRow.Select
Selection.EntireColumn.Select
Selection.EntireRow.Select
Select active column / row
ActiveSheet.Columns(ActiveCell.Column).EntireColumn.Select
ActiveSheet.Rows(ActiveCell.Row).EntireRow.Select
Would something like this work for you?
Dim StartPoint As Range
Set StartPoint = ActiveCell
StartPoint.EntireColumn.Insert
'or StartPoint.EntireRow.Insert
StartPoint.EntireColumn.Copy Destination:=StartPoint.Offset(0, -1)
'or StartPoint.Entirerow.Copy _
Destination:=StartPoint.Offset(-1, 0)
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Unprotect
If Range("E2").Value = 0 Then
Columns("G:H").EntireColumn.Hidden = True
Else
Columns("G:H").EntireColumn.Hidden = False
End If
If Range("E1").Value = 0 Then
Columns("B").EntireColumn.Hidden = True
Else
Columns("B").EntireColumn.Hidden = False
End If
If Range("I4").Value = 0 Then
Columns("I").EntireColumn.Hidden = True
Else
Columns("I").EntireColumn.Hidden = False
End If
If Range("J4").Value = 0 Then
Columns("J").EntireColumn.Hidden = True
Else
Columns("J").EntireColumn.Hidden = False
End If
If Range("K4").Value = 0 Then
Columns("K").EntireColumn.Hidden = True
Else
Columns("K").EntireColumn.Hidden = False
End If
If Range("L4").Value = 0 Then
Columns("L").EntireColumn.Hidden = True
Else
Columns("L").EntireColumn.Hidden = False
End If
If Range("M4").Value = 0 Then
Columns("M").EntireColumn.Hidden = True
Else
Columns("M").EntireColumn.Hidden = False
End If
If Range("N4").Value = 0 Then
Columns("N").EntireColumn.Hidden = True
Else
Columns("N").EntireColumn.Hidden = False
End If
If Range("O4").Value = 0 Then
Columns("O").EntireColumn.Hidden = True
Else
Columns("O").EntireColumn.Hidden = False
End If
If Range("P4").Value = 0 Then
Columns("P").EntireColumn.Hidden = True
Else
Columns("P").EntireColumn.Hidden = False
End If
If Range("Q4").Value = 0 Then
Columns("Q").EntireColumn.Hidden = True
Else
Columns("Q").EntireColumn.Hidden = False
End If
If Range("R4").Value = 0 Then
Columns("R").EntireColumn.Hidden = True
Else
Columns("R").EntireColumn.Hidden = False
End If
ActiveSheet.Protect
End Sub