使用Excel中的值创建文件夹

时间:2017-06-23 00:50:52

标签: excel vba excel-vba

这个地方已经多次救了我,所以我又来了。我正在尝试使用Visual Basic从excel电子表格创建文件夹 - 我已经设法在网络上找到这个简单的解决方案 - 但是我还想使用相邻单元格中的值:

Sub MakeFolders()
Dim Rng As Range
Dim maxRows, maxCols, r, c As Integer
Set Rng = Selection
maxRows = Rng.Rows.Count
maxCols = Rng.Columns.Count
For c = 1 To maxCols
r = 1
Do While r <= maxRows
If Len(Dir(ActiveWorkbook.Path & "\" & Rng(r, c), vbDirectory)) = 0 Then
MkDir (ActiveWorkbook.Path & "\" & Rng(r, c))
On Error Resume Next
End If
r = r + 1
Loop
Next c
End Sub

我猜它最终会看起来像......

(ActiveWorkbook.Path & "\" & Rng(r, c) & Rng(r, c).Offset(0, 12))

但我老实说抓着稻草,任何帮助都会很棒。

0 个答案:

没有答案