Commandbutton
왼쪽에있는 셀에 날짜를 붙여 넣는 기능이있는를 만들고 싶습니다. 나중에이 버튼을 아래에 복사해야합니다.
나는 노력하고있다 :
Private Sub CommandButton2_Click()
Dim Str As String
Str = Date
Range(TopLeftCell).Value = Str
End Sub
Form Control
대신 사용 하는 것이 좋으며 ActiveX control
그 이유는 매우 간단합니다. 단추를 복사 할 때 매크로에 대한 링크는 그대로 유지됩니다. , 이는 또한 귀하의 요구 사항 중 하나입니다.
그리고 이것은 CommandButton (Form Control)에 사용할 수있는 코드입니다.
Sub Button1_Click()
Dim cellAddr As String
Dim aCol As Long
'~~> Get the address of the cell
cellAddr = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address
'~~> Also get the column number
aCol = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Column
'~~> This is required if the button is in column 1
If aCol <> 1 Then _
ActiveSheet.Range(cellAddr).Offset(, -1).Value = Date
End Sub
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다