LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 211
Default Why won't this work

Hi...the code crashes on...

Sub FileNamer() - highlighted in yellow

and

Do Until FileName$ = "" - FileNames$ is highlighted in grey

Error message says...

Type declration character does not match the correct data type.

Any thoughts...

Thanks so far.

Gordon...

"Kaak" wrote:


Maybe try this

Sub FileNamer()

Dim a, FilePath, FileName, DestPath As String
Dim wbActiveWorkbook As Workbook
Dim aStart As Integer

Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual

'EDIT TO MATCH PATH THAT CONTAINS YOUR FILES
FilePath = "C:\Desktop\Raw1\"

'EDIT TO MATCH FOLDER TO HOLD YOUR NEW FILES (MUST BE DIFFERENT
FROM Source Dir)
DestPath = "C:\tested\"
If Dir(DestPath, vbDirectory) = "" Then MkDir (DestPath$)

FileName = Dir(FilePath & "*.xls")
Do Until FileName$ = ""

Set wbActiveWorkbook = Workbooks.Open(FilePath & FileName, 0,
1)
a = CStr(wbActiveWorkbook.Sheets("Summary").Range("D3" ).Value)

For x = 1 To Len(a)
If IsNumeric(Mid(a, x, 1)) = True Then
aStart = x
a = Right(a, Len(a) - aStart + 1)
a = Trim(Left(a, InStr(a, " ")))
GoTo NumFound
End If
Next x

NumFound:

wbActiveWorkbook.SaveAs DestPath & a & ".xls"
wbActiveWorkbook.Close 0

FileName = Dir

Loop

Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
MsgBox "done"

End Sub


--
Kaak
------------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...fo&userid=7513
View this thread: http://www.excelforum.com/showthread...hreadid=566599


 
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
how can i automatically generate work order numbers from work orde rob h Excel Discussion (Misc queries) 1 July 13th 09 07:59 PM
flash object dont work in my excel work sheet Nitn Excel Discussion (Misc queries) 0 July 4th 09 08:00 AM
If I have a work sheet protected and try to run a macro to hide rows or columns it won't work. Correct? Marc Excel Programming 2 July 12th 06 04:10 AM
Counting dates in multiple work sheets and work books Savage Excel Discussion (Misc queries) 0 December 19th 05 11:41 PM
Is there away to keep "auto save" from jumping to the first work sheet in the work book? Marc New Users to Excel 2 April 21st 05 01:27 AM


All times are GMT +1. The time now is 04:10 PM.

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

About Us

"It's about Microsoft Excel"