ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copying and then reselecting a workbook with VBA (https://www.excelbanter.com/excel-programming/280189-copying-then-reselecting-workbook-vba.html)

Big Chris[_9_]

Copying and then reselecting a workbook with VBA
 
Hello!

Thanks for at least looking at my request....

I have a workbook and I have recorded a macro to copy a sheet to a new
workbook and then paste the values to get rid of all the formulae.
I then want to return to the original workbook to make further changes
with the same macro. Problem is, the original worksheet may not have
been saved under a common name. It there a way with VBA to reselect the
original sheet regardless of its name?

Everything works fine with a known workbook name specified in the
macro.


Many thanks,



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/


[email protected]

Copying and then reselecting a workbook with VBA
 
Dim wSht as WorkSheet
Dim wBk as WorkBook

Set wSht = ActiveSheet
Set wBk = ActiveWorkbook

' Your sheet copy code.

wBk.Activate
wSht.Activate

HTH
Paul
---------------------------------------------------------------------------------
Hello!

Thanks for at least looking at my request....

I have a workbook and I have recorded a macro to copy a sheet to a new
workbook and then paste the values to get rid of all the formulae.
I then want to return to the original workbook to make further changes
with the same macro. Problem is, the original worksheet may not have
been saved under a common name. It there a way with VBA to reselect the
original sheet regardless of its name?

Everything works fine with a known workbook name specified in the
macro.


Many thanks,




All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com