Predefine a named range for an exported SQL Server Reporting Services report

Tags:
Excel 2003
Microsoft Excel
Microsoft Excel 2003
SQL Server Reporting Services
SSRS
How can you predefine a named range for an SQL Server Reporting Services report exported to Excel? In particular, the named range must have a specific name, along with referring to a set of cells with specific columns for all rows rendered for the given table control. I am running SQL Server 2005 SP3 with Microsoft Excel 2003.

Answer Wiki

Thanks. We'll let you know when a new response is added.

This function will name a range for you.

Function NameRange(strName As String, strRange as String) As Boolean

strName = Replace(strName,” “,”_”)

On Error Resume Next
ThisWorkbook.Names.Add Name:=strName, _
RefersTo:=”=” & strRange, Visible:=True
If Err = 0 Then
NameRange = True
End If
On Error Goto 0

End Function

To call it, pass in the name you want, and the range it refers to. Ex:

Call NameRange(“My Range”,”A1:B100″)

The function returns boolean TRUE if successful. Also note that spaces are not allowed, so the function converts spaces to underscores.

HTH

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • SQL Server Ask the Experts
    [...] http://itknowledgeexchange.techtarget.com/itanswers/predefine-a-named-range-for-an-exported-sql-serv... [...]
    0 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following