How to get named excel sheets while exporting from SSRS

后端 未结 10 1231
粉色の甜心
粉色の甜心 2020-12-08 14:17

Whenever a single page report is exported to excel, sheet in excel is named by the report name. If a report has multiple pages, the sheets are named as sheet1, sheet2,.... I

10条回答
  •  隐瞒了意图╮
    2020-12-08 14:23

    Put the tab name on the page header or group TableRow1 in your report so that it will appear in the "A1" position on each Excel sheet. Then run this macro in your Excel workbook.

    Sub SelectSheet()
            For i = 1 To ThisWorkbook.Sheets.Count
            mysheet = "Sheet" & i
            On Error GoTo 10
            Sheets(mysheet).Select
            Set Target = Range("A1")
            If Target = "" Then Exit Sub
            On Error GoTo Badname
            ActiveSheet.Name = Left(Target, 31)
            GoTo 10
    Badname:
            MsgBox "Please revise the entry in A1." & Chr(13) _
            & "It appears to contain one or more " & Chr(13) _
            & "illegal characters." & Chr(13)
            Range("A1").Activate
    10
            Next i
    End Sub
    

提交回复
热议问题