Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
compile/syntax error to save active book to new location on networ Sharon Excel Worksheet Functions 2 March 14th 07 07:51 PM
VBAProject name compile error, not defined at compile time Matthew Dodds Excel Programming 1 December 13th 05 07:17 PM
Need Help with Programming-Syntax/Compile Errors clk[_2_] Excel Programming 6 January 17th 05 11:21 PM
VLOOKUP Compile/Syntax Error JimFor Excel Programming 4 December 22nd 04 06:10 PM


All times are GMT +1. The time now is 03:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"