반응형
□ Main Code
Sub GetSelectedCellValue()
Dim selectedObject As Object
Dim cellValue As Variant
On Error GoTo ErrorHandler
'// Save the user selected object to a variable
Set selectedObject = Selection
'// Check if the selection is a single Range
If TypeOf selectedObject Is Range And selectedObject.Areas.Count = 1 Then
'// Get the value of the selected cell
cellValue = selectedObject.Value
'// Display warning message if cell value is empty
If IsEmpty(cellValue) Then
MsgBox "The selected cell is empty"
Exit Sub
End If
'// Output the retrieved value to a message box
MsgBox "The value of the selected cell is " & cellValue
Else
MsgBox "Please select only a single cell."
Exit Sub
End If
Exit Sub
ErrorHandler:
MsgBox "형식이 일치하지 않습니다. 다시 시도해주세요."
End Sub
'VBA VB.Net Code' 카테고리의 다른 글
엑셀 VBA의 Collection (0) | 2024.11.15 |
---|---|
Solidworks API를 이용하여 응용 프로그램 개발 하기 (1) | 2024.11.08 |
Excel Cell 내용 가져오기, Cell에 내보내기 (0) | 2024.09.09 |
Cell 값을 조합하기 (0) | 2024.08.30 |
학습 04) Open API, 엑셀 VBA (0) | 2024.06.24 |