saving twice for each file

mthrall

New Member
Joined
Dec 22, 2005
Messages
1
HI guys

i wonder if anyone can help me. I have written a macro which will export small sections of a large data file and save each section as seperate msdos txt files. the problem is that the macro trys to save each file twice making windows to promt me every time to overite the data. i wouldent mind but i have a huge number of files and the idea behind the macro is to be automated.

can anyone please help as this is really bugging me

' output Macro
' Macro recorded 14/12/2005 by Materials Science Centre
'
' Keyboard Shortcut: Ctrl+o

Dim i As Integer
Dim j As Integer
j = 4

For i = 0 To 1
Set NewBook = Workbooks.Add
fname = "BZN_j"
Windows("6.2conversion.xls").Activate
Range("E7:E4102").Select
Selection.Copy
Windows(2).Activate
ActiveWindow.WindowState = xlNormal
Range("A1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Windows("6.2conversion.xls").Activate
ActiveWindow.WindowState = xlNormal
Windows("6.2conversion.xls").Activate
Range(Cells(7, 7 + (2 * i)), Cells(4102, 7 + (2 * i))).Select
Application.CutCopyMode = False
Selection.Copy
Windows(2).Activate
ActiveWindow.WindowState = xlNormal
Range("B1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.DefaultSaveFormat = xlTextMSDOS
ActiveSheet.SaveAs Filename:="BZN" & j, FileFormat:=xlTextMSDOS, CreateBackup:=False
Workbooks(2).Close
j = j + 1
Next i

End Sub
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top