View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Nigel[_2_] Nigel[_2_] is offline
external usenet poster
 
Posts: 735
Default Creating directories from given column of data

Well spotted!

--

Regards,
Nigel




"carlo" wrote in message
...
Don't forget the typo:

Set myR = .Range(.Cells(mFirstRow, mDataCol), .Cells(Rows.Count,
mDatCol).End(xlUp))

should be

Set myR = .Range(.Cells(mFirstRow, mDataCol), .Cells(Rows.Count,
mDataCol).End(xlUp))


Carlo

On Jan 15, 2:44 pm, "Nigel" wrote:
Other than checking for word wraps as suggested by Carlo if all looks OK.

In the VBE (Press Alt-F11) and check that the error detection is set
correctly, goto Tools Options General (tab) and set Error Trapping to
'Break on Unhandled Errors'.

--

Regards,
Nigel


"Kelly" wrote in message

...



Many thanks again, Nigel, for taking the time to review my post.


I attempted to substitute the new code you posted in place of the
original Column A specific code. I'm getting a run time error and
imagine I've screwed the placement up.


Sub CreateDirectoy()
Dim myR As Range, c As Range
Dim strDir As String
Dim mFirstRow As Long, mDataCol As String
mFirstRow = 1 ' this is the first row of directory names
mDataCol = "B" ' this is the column of names to use
With Sheets("Sheet1")


Set myR = .Range(.Cells(mFirstRow, mDataCol), .Cells(Rows.Count,
mDatCol).End(xlUp))


' loop through each cell value
For Each c In myR


' using your code
strDir = "C:\Documents and Settings\Administrator\Desktop\FOLDERS\"
& Trim(c.Value)
On Error Resume Next
If Dir(strDir) = "" Then MkDir strDir


Next


End With
End Sub


Anything look out of place?


*** Sent via Developersdexhttp://www.developersdex.com***- Hide quoted
text -


- Show quoted text -