ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   automated macro's? and macro limitation to a worksheet (https://www.excelbanter.com/excel-programming/281285-automated-macros-macro-limitation-worksheet.html)

FAM THEUWS

automated macro's? and macro limitation to a worksheet
 
1) Is there a way to automatically copy the content of a worksheet to a file
which has the name of that worksheet.
2) Is it possible to assign and limit a macro to a worksheet. I'm only
capable to attach a macro to a complete .xls file.



Dick Kusleika[_3_]

automated macro's? and macro limitation to a worksheet
 
FAM


1) Is there a way to automatically copy the content of a worksheet to a

file
which has the name of that worksheet.


Dim wb as Workbook
Dim sh as Worksheet

Set sh = ActiveSheet
Set wb = sh.Copy
wb.SaveAs sh.Name

Using Copy on a worksheet creates a new workbook with only that sheet. You
can then save the new workbook using the sheet's name.

2) Is it possible to assign and limit a macro to a worksheet. I'm only
capable to attach a macro to a complete .xls file.



Why? You can write a macro such that it only acts on a specific sheet or
can only be called by a specific sheet.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.




All times are GMT +1. The time now is 02:06 PM.

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