Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Make this the active workbook
How can I make this code work in whatever workbook is the current active
workbook? Right now, the only way it will work is to paste it into the workbook module. I want to put it in my personal.xls and run it from any workbook. Thanks. Sub Mail_every_Worksheet() Dim sh As Worksheet Dim wb As Workbook Dim strdate As String ShtCount = ActiveWorkbook.Sheets.Count <===== I thought this did it, but it doesn't do the trick Application.ScreenUpdating = False For Each sh In ThisWorkbook.Worksheets If sh.Range("a1").Value Like "*@*" Then strdate = Format(Now, "dd-mm-yy h-mm-ss") sh.Copy Set wb = ActiveWorkbook With wb .SaveAs "Sheet " & sh.name & " of " _ & ThisWorkbook.name & " " & strdate & ".xls" .SendMail ActiveSheet.Range("a1").Value, _ "This is the Subject line" .ChangeFileAccess xlReadOnly Kill .FullName .Close False End With End If Next sh Application.ScreenUpdating = True End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to make only the cells i need active | Excel Worksheet Functions | |||
copy worksheet from closed workbook to active workbook using vba | Excel Worksheet Functions | |||
Make a particular cell the active one | Excel Programming | |||
How do I make an open workbook the active workbook | Excel Programming | |||
Preventing opening workbook inside active workbook. | Excel Programming |