VBA New Work Book adding problem !

mikeprice53

Active Member
Joined
Jan 21, 2003
Messages
297
Please refer to the VBA below

Dim NewWb As Workbook

t = Time
d = Date


If Chk_Save2File = True Then

Set NewWB = Workbooks.Add
NewWB.Activate
Windows("Import Calculator 20").Activate
Sheets("PRINTOFFSHEETAFTBP").Select
Sheets("PRINTOFFSHEETAFTBP").Copy


ChDir "G:\"
ActiveWorkbook.SaveAs Filename:="G:\FAMALBUM\Imports Calculator\Saved Results\" & Cusn & "-" & "AftBP" & "-" & Format(d, "ddmmmyy") & "@" & Format(t, "hh-mm") & ".xls", FileFormat:=xlNormal _
, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
Range("B9").Select

End If

my problem is that when it opens up another workbook to paste the data into it opens up two and does what it is supposed to to the second one but leaves teh first one open, all I want is the one workbook to save and close as stated in teh code !

Please help
 

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

mikeprice53

Active Member
Joined
Jan 21, 2003
Messages
297
ok ok ok !

I sussed it :0)

Was being a little small minded when I I was adding a new workbook...

On the copy command it already adds a new workbook so thats where the 2nd one came from ! ;0)
 

P Sitaram

Well-known Member
Joined
Jun 24, 2003
Messages
1,974
The code relating to creation of new Workbook is not needed as you are using the Save As menthod.

Remove all the lines pertaining to the New Workbook.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,385
Messages
5,595,869
Members
414,027
Latest member
zippyfrog

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
Top