![]() |
Define name automatically
In selected range, for example a1:d234 I need to
give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne |
Define name automatically
For i = 1 To 234 Range("A1").Resize(,4).Name = "row" & i Next i -- HTH RP (remove nothere from the email address if mailing direct) "arne" wrote in message ... In selected range, for example a1:d234 I need to give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne |
Define name automatically
Tried it. It gives different name for the same range
=Sheet1!$A$1:$D$1 In selected range, for example a1:d234 I need to give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne |
Define name automatically
I'm guessing you're testing your macro with something like:
Option Explicit Sub testme() Dim nm As Name Dim i As Long For i = 1 To 2 '234 Range("A1").Resize(, 4).Name = "row" & i Next i For Each nm In Names MsgBox nm 'try this instead: msgbox nm.name Next nm End Sub arne wrote: Tried it. It gives different name for the same range =Sheet1!$A$1:$D$1 In selected range, for example a1:d234 I need to give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne -- Dave Peterson |
Define name automatically
Ahhh...
or: Dim i As Long For i = 1 To 234 Cells(i, "A").Resize(, 4).Name = "row" & i Next i But I'd use: Dim i As Long For i = 1 To 234 Cells(i, "A").Resize(, 4).Name = "row" & format(i,"000") Next i I like row001, row002, ... Herbert wrote: Hi, Arne is right, all created names refer to A1:D1 Try this: Dim oName As Name, nRow As Long Dim oSheet As Worksheet Set oSheet = ActiveSheet For nRow = 1 To 20 oSheet.Names.Add "row" & nRow, "=" & oSheet.Name & "!$A$" & nRow & ":$D$" & nRow Next nRow Regards, Herbert "arne" wrote: Tried it. It gives different name for the same range =Sheet1!$A$1:$D$1 In selected range, for example a1:d234 I need to give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne -- Dave Peterson |
Define name automatically
You are all clever and helpfull! I have one problem with your solutions: I
do not always have 234 rows. In one way or another i must count the number of rows in my selection. (the numbers of columns is fixed, but a genious solutions is to count the numbers of columns in my selections) Arne "arne" skrev i melding ... In selected range, for example a1:d234 I need to give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne |
Define name automatically
Can you find the last row in column A and use that?
Dim i As Long Dim LastRow as long lastrow = cells(rows.count,"A").end(xlup).row For i = 1 To Lastrow Cells(i, "A").Resize(, 4).Name = "row" & format(i,"000") Next i arne wrote: You are all clever and helpfull! I have one problem with your solutions: I do not always have 234 rows. In one way or another i must count the number of rows in my selection. (the numbers of columns is fixed, but a genious solutions is to count the numbers of columns in my selections) Arne "arne" skrev i melding ... In selected range, for example a1:d234 I need to give a1:d1 the name row1,a2:d2 the name row2 and so on.. Any suggestions? Using excel 2000. Arne -- Dave Peterson |
All times are GMT +1. The time now is 12:19 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com