ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Syntax and compile error. (https://www.excelbanter.com/excel-programming/357069-syntax-compile-error.html)

Jim15[_16_]

Syntax and compile error.
 

I am getting a syntax and compile error on the dim cou .... line. Any
suggestions?

Thanks,

Jim

Sub createfolders()
'
'
dim cou as integer,Dim FolderStr as string, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C:\ + RESERVES
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=526198


Chip Pearson

Syntax and compile error.
 
While you can Dim more than one variable on a line of code, you
need to use only a single Dim keyword.

Change
dim cou as integer,Dim FolderStr as string, FileSys
to
dim cou as integer, FolderStr as string, FileSys


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jim15"
wrote in message
...

I am getting a syntax and compile error on the dim cou ....
line. Any
suggestions?

Thanks,

Jim

Sub createfolders()
'
'
dim cou as integer,Dim FolderStr as string, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C:\ + RESERVES
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile:
http://www.excelforum.com/member.php...o&userid=26300
View this thread:
http://www.excelforum.com/showthread...hreadid=526198




Jim Thomlinson

Syntax and compile error.
 
You can't use dim twice on the same line. Try either of the two following

dim cou as integer
Dim FolderStr as string
dim FileSys as variant

or

dim cou as integer, FolderStr as string, FileSys
--
HTH...

Jim Thomlinson


"Jim15" wrote:


I am getting a syntax and compile error on the dim cou .... line. Any
suggestions?

Thanks,

Jim

Sub createfolders()
'
'
dim cou as integer,Dim FolderStr as string, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C:\ + RESERVES
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=526198



Dave Peterson

Syntax and compile error.
 
Dim Cou As Long: Dim foldersys As String: Dim filesys As Variant

But that's way too ugly for even me.

Jim Thomlinson wrote:

You can't use dim twice on the same line. Try either of the two following

dim cou as integer
Dim FolderStr as string
dim FileSys as variant

or

dim cou as integer, FolderStr as string, FileSys
--
HTH...

Jim Thomlinson

"Jim15" wrote:


I am getting a syntax and compile error on the dim cou .... line. Any
suggestions?

Thanks,

Jim

Sub createfolders()
'
'
dim cou as integer,Dim FolderStr as string, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C:\ + RESERVES
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=526198



--

Dave Peterson

Jim15[_18_]

Syntax and compile error.
 

I am getting a compile error on the C: RESERVES saying "function not
defined". I want to create a folder called C:\RESERVES on my hard
drive and subfolders with what is in column A on my Excel spreadsheet.
We're almost there!

Thanks,

Jim

Sub createfolders()
'
' CreateFolders Macro
' Macro recorded 3/22/2006 by JBW
'
Dim cou As Integer, FolderStr As String, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C: RESERVES
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=526198


Chip Pearson

Syntax and compile error.
 
Replace
FileSys.createfolder C: RESERVES
with
FileSys.createfolder "C:\RESERVES"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Jim15"
wrote in message
...

I am getting a compile error on the C: RESERVES saying
"function not
defined". I want to create a folder called C:\RESERVES on my
hard
drive and subfolders with what is in column A on my Excel
spreadsheet.
We're almost there!

Thanks,

Jim

Sub createfolders()
'
' CreateFolders Macro
' Macro recorded 3/22/2006 by JBW
'
Dim cou As Integer, FolderStr As String, FileSys
For cou = 1 To ActiveSheet.UsedRange.Rows.Count
FolderStr = Format(Trim(Str(cou)), "00#") + "_" +
ActiveSheet.Cells(cou, 1)
Set FileSys = CreateObject("Scripting.FileSystemObject")
FileSys.createfolder C: RESERVES
Next
End Sub


--
Jim15
------------------------------------------------------------------------
Jim15's Profile:
http://www.excelforum.com/member.php...o&userid=26300
View this thread:
http://www.excelforum.com/showthread...hreadid=526198




Jim15[_19_]

Syntax and compile error.
 

Thanks. I am now getting an error that says "File already exists". The
routine is creating a folder called C:\RESERVES but not creating the
subfolders. I have the letters A - O in rows 1 - 15 of the Excel
spreadsheet but it is not creating those subfolders in RESERVES.

Jim


--
Jim15
------------------------------------------------------------------------
Jim15's Profile: http://www.excelforum.com/member.php...o&userid=26300
View this thread: http://www.excelforum.com/showthread...hreadid=526198



All times are GMT +1. The time now is 05:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com