speed-star
New Member
Hi All,
could anyone help me
I need macro to copy one sheet into new workbook and attach it in outlook,
I found this code, but unfortunately this code was copied all sheets in the workbook.
instead of one sheet that I want.
let say that selected sheet I want to choose is only in range "rangeSheet".
'Set up for some shorthand
Set wsTarget = ActiveWorkbook.Worksheets(strSheetEmail)
strFilePath = ActiveWorkbook.Path & Application.PathSeparator
'Retrieve the sheets to print
For Each cl In wsTarget.Range("rangeSheet")
sSheetsToPrint = sSheetsToPrint & cl.Value & ","
Next cl
sSheetsToPrint = Left(sSheetsToPrint, Len(sSheetsToPrint) - 1)
sSheets() = Split(sSheetsToPrint, ",")
Set srcWB = ActiveWorkbook
For Each sht In srcWB.Sheets
sht.Copy
Set destWB = ActiveWorkbook
destWB.SaveAs strFilePath & strSheetPrefix & sht.Name & ".xlsx"
destWB.Close
Next
could anyone help me
I need macro to copy one sheet into new workbook and attach it in outlook,
I found this code, but unfortunately this code was copied all sheets in the workbook.
instead of one sheet that I want.
let say that selected sheet I want to choose is only in range "rangeSheet".
'Set up for some shorthand
Set wsTarget = ActiveWorkbook.Worksheets(strSheetEmail)
strFilePath = ActiveWorkbook.Path & Application.PathSeparator
'Retrieve the sheets to print
For Each cl In wsTarget.Range("rangeSheet")
sSheetsToPrint = sSheetsToPrint & cl.Value & ","
Next cl
sSheetsToPrint = Left(sSheetsToPrint, Len(sSheetsToPrint) - 1)
sSheets() = Split(sSheetsToPrint, ",")
Set srcWB = ActiveWorkbook
For Each sht In srcWB.Sheets
sht.Copy
Set destWB = ActiveWorkbook
destWB.SaveAs strFilePath & strSheetPrefix & sht.Name & ".xlsx"
destWB.Close
Next