Estou usando um código VBA para criar uma nova pasta em um diretório. O que eu quero fazer é obter o novo nome da pasta na célula selecionada. Alguma idéia de como posso fazer isso, por favor?
Aqui está o código que tenho até agora.
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
Responder1
Eu tentaria algo assim:
Dim folderNameCell As Range
Dim newFolderName As String
Set folderNameCell = Application.Selection
newFolderName = folderNameCell.Value