S
Steven Cheng
I have the following code which looks into a named range
(emaillist) and copies and pastes certain ranges (defined
in this emaillist range) to another workbook (which I will
later email out. However, the copying and pasting should
only be by value and format. I have included the code in
but it still isn't working for some reason. The ranges
that it is pulling from are noncontinguous hence why I
have the range names listed in the emaillist. Everything
works fine up to the adding and copy but not the
pastespecial feature for some reason. Can anyone help
me...I am so close but yet so far.
Sub Reporting()
Dim a, b, c As String
Dim email As Range
Dim r, y As Integer
Dim wkb, cwkb As Workbook
'
' Macro2 Macro
' Macro recorded 07/25/2003 by Steven Cheng
'
'
a = "Period " & Format(Worksheets("Hotel_Info").Range
("Period").Value, "00")
a = a & ", Day " & Format(Worksheets
("Hotel_Info").Range("Current_day").Value, "00")
a = a & " " & Format(Worksheets("Hotel_Info").Range
("Year").Value, "0000")
a = a & " - " & Format(Worksheets("Hotel_info").Range
("Report_Date").Value, "mm/dd/yyyy")
Set email = Worksheets("Hotel_info").Range("emaillist")
' cwkb = ActiveWorkbook
With Worksheets("Report")
For r = 1 To email.Rows.Count
b = .Range("Titles").Address & "," & .Range
("Summary_lbr").Address
For y = 1 To email.Columns.Count
If Trim(email.Cells(r, y + 1).Text) <> ""
Then
b = b & "," & .Range(email.Cells(r, y
+ 1).Text).Address
End If
Next
.Range(b).Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlValue
Selection.PasteSpecial Paste:=xlFormats
Next
End With
' .SendMail Recipients:="(e-mail address removed)"
End Sub
(emaillist) and copies and pastes certain ranges (defined
in this emaillist range) to another workbook (which I will
later email out. However, the copying and pasting should
only be by value and format. I have included the code in
but it still isn't working for some reason. The ranges
that it is pulling from are noncontinguous hence why I
have the range names listed in the emaillist. Everything
works fine up to the adding and copy but not the
pastespecial feature for some reason. Can anyone help
me...I am so close but yet so far.
Sub Reporting()
Dim a, b, c As String
Dim email As Range
Dim r, y As Integer
Dim wkb, cwkb As Workbook
'
' Macro2 Macro
' Macro recorded 07/25/2003 by Steven Cheng
'
'
a = "Period " & Format(Worksheets("Hotel_Info").Range
("Period").Value, "00")
a = a & ", Day " & Format(Worksheets
("Hotel_Info").Range("Current_day").Value, "00")
a = a & " " & Format(Worksheets("Hotel_Info").Range
("Year").Value, "0000")
a = a & " - " & Format(Worksheets("Hotel_info").Range
("Report_Date").Value, "mm/dd/yyyy")
Set email = Worksheets("Hotel_info").Range("emaillist")
' cwkb = ActiveWorkbook
With Worksheets("Report")
For r = 1 To email.Rows.Count
b = .Range("Titles").Address & "," & .Range
("Summary_lbr").Address
For y = 1 To email.Columns.Count
If Trim(email.Cells(r, y + 1).Text) <> ""
Then
b = b & "," & .Range(email.Cells(r, y
+ 1).Text).Address
End If
Next
.Range(b).Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlValue
Selection.PasteSpecial Paste:=xlFormats
Next
End With
' .SendMail Recipients:="(e-mail address removed)"
End Sub