View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
JLGWhiz JLGWhiz is offline
external usenet poster
 
Posts: 3,986
Default Create Folder Variable


Dim rCell As Range, rRng As Range

With Sheet1
Set rRng = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each rCell In rRng.Cells

If rCell.Offset(0, 4).Value = "Colorado" Then
myFolder = rCell.Offset(0, 4).Value
myPath = "C:\InvestorFiles\United States\"
CreateFolders rCell.Value, myPath & myFolder

End If
Next rCell


"Kerry" wrote:

I would like to create a variable that I can use to replace portion of my
create folder path. I am using this code to create folders. I would like to
replace the state "Colorado" as a variable based on a column of data in my
speard sheet. I just haven't been able to figure this out. Any when would be
appriciated.

Can the folder path be a variable as well based on a column of data?


Sub StartHere()

Dim rCell As Range, rRng As Range

With Sheet1
Set rRng = .Range("A2", .Cells(.Rows.Count, "A").End(xlUp))
End With

For Each rCell In rRng.Cells

If rCell.Offset(0, 4).Value = "Colorado" Then

CreateFolders rCell.Value, "C:\InvestorFiles\United States\Colorado"

End If
Next rCell

End Sub