Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am new to this VBA thing so any help would be welcome.
I need to create a file folder for all of the companies listed in column F of my worksheet. I have a button on the worksheet with the following line of code attached but can not see how to move down to the next row. Also is there a way to check if the folder exists, if it does to ignore it and move to the next row. Thanks Andy Private Sub CommandButton1_Click() Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.createfolder("E:/Customers and Contacts/") a.Close End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() "Andy" wrote in message ... I am new to this VBA thing so any help would be welcome. I need to create a file folder for all of the companies listed in column F of my worksheet. I have a button on the worksheet with the following line of code attached but can not see how to move down to the next row. Also is there a way to check if the folder exists, if it does to ignore it and move to the next row. Thanks Andy Private Sub CommandButton1_Click() Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.createfolder("E:/Customers and Contacts/") a.Close End Sub This is what I found. It looks pretty similar to your code except for the "/" you have at the end of the path. Remove it and see what happens. Oh, make sure the folder doesn't exist when you run the code. You may want to do that in your code in order to avoid errors. Sub CreateFolder Dim fso, fldr Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.CreateFolder("C:\MyTest") Response.Write "Created folder: " & fldr.Name End Sub/Fredrik |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Fredrik
Thanks, but how do I add the company name on each row of my worksheet to the end of E:/customers and contacts/ I need to get for example E:/customers and contacts/companyA E:/customers and contacts/companyB E:/customers and contacts/companyC This will all come from column F on my worksheet. Thanks in advance Andy -----Original Message----- "Andy" wrote in message ... I am new to this VBA thing so any help would be welcome. I need to create a file folder for all of the companies listed in column F of my worksheet. I have a button on the worksheet with the following line of code attached but can not see how to move down to the next row. Also is there a way to check if the folder exists, if it does to ignore it and move to the next row. Thanks Andy Private Sub CommandButton1_Click() Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.createfolder("E:/Customers and Contacts/") a.Close End Sub This is what I found. It looks pretty similar to your code except for the "/" you have at the end of the path. Remove it and see what happens. Oh, make sure the folder doesn't exist when you run the code. You may want to do that in your code in order to avoid errors. Sub CreateFolder Dim fso, fldr Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.CreateFolder("C:\MyTest") Response.Write "Created folder: " & fldr.Name End Sub/Fredrik . |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() wrote in message ... Fredrik Thanks, but how do I add the company name on each row of my worksheet to the end of E:/customers and contacts/ I need to get for example E:/customers and contacts/companyA E:/customers and contacts/companyB E:/customers and contacts/companyC This will all come from column F on my worksheet. Thanks in advance Andy I'm not sure I understand. Do you have the paths in some cells? In that case you must loop over this range. Here's a link: http://www.ozgrid.com/VBA/VBALoops.htm /Fredrik |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub CommandButton1_Click()
Dim i As Long Dim cLastRow As Long cLastRow = Cells(Rows.Count,"A").End(xlUp).Row For i = 1 To cLastRow mkdir cells(i,"A").Value Next i End Sub This assumes your folder names start in A1, and go down column A, and that the folder E:/customers and contacts/exists already. -- HTH RP (remove nothere from the email address if mailing direct) wrote in message ... Fredrik Thanks, but how do I add the company name on each row of my worksheet to the end of E:/customers and contacts/ I need to get for example E:/customers and contacts/companyA E:/customers and contacts/companyB E:/customers and contacts/companyC This will all come from column F on my worksheet. Thanks in advance Andy -----Original Message----- "Andy" wrote in message ... I am new to this VBA thing so any help would be welcome. I need to create a file folder for all of the companies listed in column F of my worksheet. I have a button on the worksheet with the following line of code attached but can not see how to move down to the next row. Also is there a way to check if the folder exists, if it does to ignore it and move to the next row. Thanks Andy Private Sub CommandButton1_Click() Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.createfolder("E:/Customers and Contacts/") a.Close End Sub This is what I found. It looks pretty similar to your code except for the "/" you have at the end of the path. Remove it and see what happens. Oh, make sure the folder doesn't exist when you run the code. You may want to do that in your code in order to avoid errors. Sub CreateFolder Dim fso, fldr Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.CreateFolder("C:\MyTest") Response.Write "Created folder: " & fldr.Name End Sub/Fredrik . |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Does this work:
Private Sub CommandButton1_Click() Dim i As Interger Dim LRow As integer LRow = Cells(Rows.Count,"F").End(xlUp).Row For i = 1 To LRow MkDir "E:/Customers and Contacts/" & cells(i,"F").Value Next i End Sub "Bob Phillips" wrote: Private Sub CommandButton1_Click() Dim i As Long Dim cLastRow As Long cLastRow = Cells(Rows.Count,"A").End(xlUp).Row For i = 1 To cLastRow mkdir cells(i,"A").Value Next i End Sub This assumes your folder names start in A1, and go down column A, and that the folder E:/customers and contacts/exists already. -- HTH RP (remove nothere from the email address if mailing direct) wrote in message ... Fredrik Thanks, but how do I add the company name on each row of my worksheet to the end of E:/customers and contacts/ I need to get for example E:/customers and contacts/companyA E:/customers and contacts/companyB E:/customers and contacts/companyC This will all come from column F on my worksheet. Thanks in advance Andy -----Original Message----- "Andy" wrote in message ... I am new to this VBA thing so any help would be welcome. I need to create a file folder for all of the companies listed in column F of my worksheet. I have a button on the worksheet with the following line of code attached but can not see how to move down to the next row. Also is there a way to check if the folder exists, if it does to ignore it and move to the next row. Thanks Andy Private Sub CommandButton1_Click() Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.createfolder("E:/Customers and Contacts/") a.Close End Sub This is what I found. It looks pretty similar to your code except for the "/" you have at the end of the path. Remove it and see what happens. Oh, make sure the folder doesn't exist when you run the code. You may want to do that in your code in order to avoid errors. Sub CreateFolder Dim fso, fldr Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.CreateFolder("C:\MyTest") Response.Write "Created folder: " & fldr.Name End Sub/Fredrik . |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Is this a question to me or the OP? If so, it is basically the same as mine,
but doesn't match his specification, namely the cell contains the full path. And you should not use an Integer variable for the line count, as there are more lines in an Excel spreadsheet than an integer can hold. -- HTH RP (remove nothere from the email address if mailing direct) "gocush" /delete wrote in message ... Does this work: Private Sub CommandButton1_Click() Dim i As Interger Dim LRow As integer LRow = Cells(Rows.Count,"F").End(xlUp).Row For i = 1 To LRow MkDir "E:/Customers and Contacts/" & cells(i,"F").Value Next i End Sub "Bob Phillips" wrote: Private Sub CommandButton1_Click() Dim i As Long Dim cLastRow As Long cLastRow = Cells(Rows.Count,"A").End(xlUp).Row For i = 1 To cLastRow mkdir cells(i,"A").Value Next i End Sub This assumes your folder names start in A1, and go down column A, and that the folder E:/customers and contacts/exists already. -- HTH RP (remove nothere from the email address if mailing direct) wrote in message ... Fredrik Thanks, but how do I add the company name on each row of my worksheet to the end of E:/customers and contacts/ I need to get for example E:/customers and contacts/companyA E:/customers and contacts/companyB E:/customers and contacts/companyC This will all come from column F on my worksheet. Thanks in advance Andy -----Original Message----- "Andy" wrote in message ... I am new to this VBA thing so any help would be welcome. I need to create a file folder for all of the companies listed in column F of my worksheet. I have a button on the worksheet with the following line of code attached but can not see how to move down to the next row. Also is there a way to check if the folder exists, if it does to ignore it and move to the next row. Thanks Andy Private Sub CommandButton1_Click() Set fs = CreateObject("Scripting.FileSystemObject") Set a = fs.createfolder("E:/Customers and Contacts/") a.Close End Sub This is what I found. It looks pretty similar to your code except for the "/" you have at the end of the path. Remove it and see what happens. Oh, make sure the folder doesn't exist when you run the code. You may want to do that in your code in order to avoid errors. Sub CreateFolder Dim fso, fldr Set fso = CreateObject("Scripting.FileSystemObject") Set fldr = fso.CreateFolder("C:\MyTest") Response.Write "Created folder: " & fldr.Name End Sub/Fredrik . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
create a file list from a folder? | Excel Discussion (Misc queries) | |||
how do you create file folder labels in excel? | New Users to Excel | |||
can I create backup file in separate folder from the original? | Setting up and Configuration of Excel | |||
How do I Create backup of excel file in other folder | Excel Discussion (Misc queries) | |||
Create Folder and Text File in folder | Excel Programming |