Creating a named range of non-contiguous cells

NinaE_11

Board Regular
Joined
Aug 18, 2020
Messages
54
Office Version
  1. 2016
Platform
  1. Windows
Hello,

Can anyone give me advice on how to include 7 non-contiguous rows past my last row? I've tried .offset, but it's clear I'm not using it in the right place. I've gotten this far and stuck because the Offset command ends up moving down my range to start in cell A8.

Private Sub NamePERange()

Dim wsDest As Worksheet
Dim lr As Long
Dim MyRange As Range

Set wsDest = Workbooks("PE Table_SC.xlsm").Worksheets(1)
wsDest.Activate

'1. Find last used row in the copy range based on data in column A
lr = wsDest.Cells(wsDest.Rows.Count, "A").End(xlUp).Row

'2. Reset, Select Range and Name it 'PE'

Set MyRange = wsDest.Range("A1:L" & lr).offset(7)
ActiveWorkbook.Names.Add _
Name:="PE", _
RefersTo:=MyRange

End Sub

Any insight would be much appreciated - thank you!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
I'm not sure what you mean by non-contiguous cells/rows in this context?

But I think you're looking for

VBA Code:
Set MyRange = wsDest.Range("A1:L" & lr + 7)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,643
Messages
6,120,702
Members
448,980
Latest member
CarlosWin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top