View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
burl_rfc burl_rfc is offline
external usenet poster
 
Posts: 24
Default Rename active sheet to contents of specific cell

Okay, now it's working fine...

I added the renaming of the sheet to the next to last step in the
macro, I'm thinking that where I had previously put it, it was causing
some problems. The finish code is below


Sub Rectangle15_Click()
Dim sh As Worksheet
Dim wb As Workbook
Dim strdate As String
Dim MyArrIndex As Long
Dim E_Mail_Count As Long
Dim cell As Range
Dim MyArr() As String
Application.ScreenUpdating = False
Worksheets("QuoteForm").Activate
Range("I10").Select
Selection.Copy
Range("L2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
For Each sh In ThisWorkbook.Worksheets
If sh.Range("L1").Value Like "?*@?*.?*" Then
strdate = Format(Now, "dd-mm-yy h-mm-ss")

E_Mail_Count =
sh.Columns("L").Cells.SpecialCells(xlCellTypeConst ants).Count
ReDim MyArr(1 To E_Mail_Count)
MyArrIndex = 1
For Each cell In
sh.Columns("L").Cells.SpecialCells(xlCellTypeConst ants)
If cell Like "*@*" Then
MyArr(MyArrIndex) = cell.Value
MyArrIndex = MyArrIndex + 1
End If
Next
ReDim Preserve MyArr(1 To MyArrIndex)

sh.Copy
Set wb = ActiveWorkbook
sh.Name = Range("b6")
With wb
.SaveAs " " & sh.Name & " " & strdate & ".xls"
.SendMail MyArr, _
"New Quote"
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With

End If

Next sh

Application.ScreenUpdating = True
ActiveSheet.Name = "QuoteForm"
Worksheets("Quote Data Entry").Activate
End Sub