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
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
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)
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,834
Messages
6,121,876
Members
449,056
Latest member
ruhulaminappu

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