How to get result in a new worksheet of a new workbook?

shrinivasshweta

New Member
Joined
Dec 29, 2016
Messages
18
Code:
With Workbooks.Add
   ActiveWorkbook.SaveAs Filename:="C:\WorkbookName1.xls"

       ActiveSheet.Name = "Results"
        .Columns("B:D").ColumnWidth = 20
        .Range("B2:D2").Value = Array("Transient Licenses", "Steady Licenses", "Static Licenses")
        .Range("B3:D3").Value = Array(transientLicense, steadyLicense, staticLicense)
    End With

After running my macro, i want the result in a new worksheet of a new workbook.
Please help me as I am just a beginner in VBA.
Thank you so much in advance. :)
 
Last edited by a moderator:

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).

HackSlash

Active Member
Joined
Nov 18, 2016
Messages
360
That "With" statement doesn't appear to be doing anything for you.

The purpose of "with" is to make all changes to an object at once instead of opening and closing the object multiple times. In your case I believe the object is "ActiveSheet"

The code that you want, to make a new sheet in a new workbook, is really short:

"ActiveSheet.Copy"

See how I put the ".copy" method into a "with" statement:

Code:
With ActiveSheet[INDENT].Name = "Results"
[/INDENT]
[INDENT].Columns("B:D").ColumnWidth = 20[/INDENT]
[INDENT].Range("B2:D2").Value = Array("Transient Licenses", "Steady Licenses", "Static Licenses")[/INDENT]
[INDENT].Range("B3:D3").Value = Array(transientLicense, steadyLicense, staticLicense)
.Copy[/INDENT]
End With

ActiveWorkbook.SaveAs Filename:="C:\NewWorkBook.xls"
 
Upvote 0

Forum statistics

Threads
1,191,707
Messages
5,988,229
Members
440,139
Latest member
ngaicuong2017

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