Predefine a named range for an exported SQL Server Reporting Services report
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.
ASKED: Feb 10, 2009  9:05 PM GMT
UPDATED: February 11, 2009  10:10:46 PM GMT
475 pts.

Answer Wiki:
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
Last Wiki Answer Submitted:  Feb 11, 2009  10:10 PM (GMT)  by  JP2112   475 pts.
To see other answers submitted to the Answer Wiki View Answer History.
Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _




 

[...] http://itknowledgeexchange.techtarget.com/itanswers/predefine-a-named-range-for-an-exported-sql-serv… [...]