View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default Code to name numerous ranges

On Monday, May 26, 2014 12:07:13 AM UTC-7, Claus Busch wrote:
Hi Howard,



Am Sun, 25 May 2014 22:55:58 -0700 (PDT) schrieb L. Howard:



I have a great deal of similar and adjacent ranges to name.




Starting in D3 and down to D100 I want the first named range to be mon_3, then mon_4 and on down to D100.




try:



Sub MyNameCoder()

Dim j As String

Dim i As Long



j = "mon"



With ActiveSheet

For i = 3 To 100

.Names.Add Name:=j & "_" & i, _

RefersTo:=.Range(.Cells(i, "D"), .Cells(i, "L"))

Next

End With



End Sub





Regards

Claus B.



Hi Claus,

Is there a way to only include the cells in columns D, F, H, J, L instead of D through L?

The cells E, G, I, K, M will be in another named range and subject to a formula referring to those ranges.

Howard