简体   繁体   中英

Autofill formula for cell names in Excel

In an Excel worksheet with rows of parameters and columns of systems like so:

        system1 system2
height    58      65
width     12      17
weight     3       5
 ...       .       .
 ...       .       .

I am looking for a way to use this data with meaningful names such as "height1", "height2". I can name the cells "height1" "height2" (Formulas->Define Name) and use it in a cell =height1. However, when autofilling by dragging the equation to the right, the name does not change to height2 and I am left with the same value of 58.

Basically, I am looking for the same behavior as autofill dragging =B2 to =B3, but with meaningful names.

Thank you.

Here is a macro for naming them all in your convention (haven't tried it but should work):

Sub NameThem()
    Dim rng As Range
    For i = 0 To 3
        For j = 0 To 1
            Set rng = Range("A1").Offset(1 + i, 1 + j)
            Call ActiveWorkbook.Names.Add(rng.End(xlToLeft).Value & j, rng)
        Next j
    Next i
End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM