VBA 코드를 사용하여 디렉터리에 새 폴더를 만들고 있습니다. 내가 원하는 것은 선택한 셀에서 새 폴더 이름을 얻는 것입니다. 어떻게 하면 될까요?
지금까지 내가 가지고 있는 코드는 다음과 같습니다.
If Target.Column = Range("B1").Column Then
If Target.Row > 7 Then
'Variable definitions
Dim FolderListRange As Range
Dim FolderRange As Variant
Dim FolderName As String
Dim ParentFolderPath As String
On Error GoTo Handle
' Set the Folder where the individual folders should be created
ParentFolderPath = "\\UKSH000-FILE06\purchasing\New Supplier Set-Ups"
Set FolderListRange = Range("B" & Target.Row).SpecialCells(xlCellTypeConstants)
For Each FolderRange In FolderListRange
FolderName = ParentFolderPath & "\" & FolderRange.Value
If FileSystem.Dir(FolderName, vbDirectory) = vbNullString Then
FileSystem.MkDir FolderName
End If
Continue:
Next
Handle:
End If
End If
답변1
나는 다음과 같은 것을 시도할 것입니다:
Dim folderNameCell As Range
Dim newFolderName As String
Set folderNameCell = Application.Selection
newFolderName = folderNameCell.Value