dantheman9
Board Regular
- Joined
- Feb 5, 2011
- Messages
- 175
Hi Im trying to add a hidden section to saving a file to a folder to all a three digit number to the start of the file name...however, I need to be able to set this number by looking in the folder selected, read each number from other files then set the new file number in the next in sequance.
eg.
the folder might have;
001 filename 1
002 another name2
003 another file name
004 file
what I would need is to be albe to set the next number to 005
Im using the following for saving;
eg.
the folder might have;
001 filename 1
002 another name2
003 another file name
004 file
what I would need is to be albe to set the next number to 005
Im using the following for saving;
Code:
Dim rng As Range
Dim wb As Workbook
Dim Fname As Variant
[COLOR=red]Dim filenumber As Long ' need to be able to set this from looking at other files
[/COLOR]Set rng = Range("A1:A211")
Set wb = Workbooks.Add
With wb
rng.Copy
.Worksheets(1).Range("A1").PasteSpecial Paste:=xlValues
ChDir (Path) ' open path as set in path option box
Application.DisplayAlerts = False
' set file name from textbox 1 (default is enter file name
Fname = Application.GetSaveAsFilename( _
InitialFileName:= [COLOR=red]filenumber[/COLOR] & " - " & TextBox1, _
filefilter:="text file, *.txt", _
Title:="Save Race File To...")
If Fname <> False Then
.SaveAs Fname, xlTextMSDOS
End If
.Close False
Application.DisplayAlerts = True
End With