how have a macro to copy a range of cells (name range) that the user specifies to a new worksheet?
how have a macro to copy a range of cells (name range) that the user specifies to a new worksheet?
Last edited by pankaj2145; 12-03-2009 at 02:03 AM.
Request is a tad vague - you don't specify how you wish to capture named range and "new worksheet" could mean create an entirely new sheet or use another sheet already created... you also need to specify what exactly you intend to copy (everything, values only (ie no formulae) etc
At a rough guess
there are plenty of other approaches - the above is just one.![]()
Sub Example() Dim nm As Name, strNm As String, vData strNm = Application.InputBox("Enter Defined Name to Copy", Type:=2) On Error Resume Next Set nm = ThisWorkbook.Names(strNm) If Not nm Is Nothing Then vData = Evaluate(nm.RefersTo) Sheets.Add After:=Sheets(Sheets.Count) If varType(vData) = 8204 Then Cells(1, "A").Resize(UBound(vData, 1), UBound(vData, 2)).Value = vData Else Cells(1,"A").Value = vData End If Set nm = Nothing Else MsgBox "Computer Says No!", vbCritical, "Error" End If End Sub
Last edited by DonkeyOte; 12-03-2009 at 04:59 AM.
My Recommended Reading:
Volatility
Sumproduct & Arrays
Pivot Intro
Email from XL - VBA & Outlook VBA
Function Dictionary & Function Translations
Dynamic Named Ranges
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks