excel vba get named range byname code example

Example 1: excel vba get user selected range

MsgBox Selection.Address

Example 2: get name of a range vba

'For a Range, Name isn t a string it s a Name object
'that you then take the Name property of to get the string

MsgBox sampleRange.Name.Name

Example 3: vba pass named range to function

Private Sub copyABU()
   Call copyPaste(ThisWorkbook.Names("myRange1").RefersToRange)
   Call copyPaste(ThisWorkbook.Names("myRange2").RefersToRange)
   Call copyPaste(ThisWorkbook.Names("myRange3").RefersToRange)
   ' //etc
End Sub

Tags:

Vb Example