ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Do Loop that names rows as ranges (https://www.excelbanter.com/excel-programming/307457-help-do-loop-names-rows-ranges.html)

fifthhorseman[_2_]

Help with Do Loop that names rows as ranges
 
Hi,

I am working on some code that will look at each row (starting at ro
2) and define the row by the value that is on the row in column 1
until the program gets to a cell that is blank, in which the loo
stops. Everything seems to be working except for one small part.
keep on getting Run-time error 1004: That Name is not valid.

The following is my code:

Private Sub cmdCatAddSyn_Click()
'Synchronize all pages with the new category
'IN PROGRESS

RCount = 2
Do Until Worksheets(1).Cells(RCount, 1).Value = ""
Worksheets(1).Rows(RCount).Name = Worksheets(1).Cells(RCount, 1)
RCount = RCount + 1
Loop
End Sub

The section of code that is always highlighted i
Worksheets(1).Rows(RCount).Name=Worksheets(1).Cell s(RCount,1)

All help is appreciated, and thank you in advance

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Help with Do Loop that names rows as ranges
 
names can't have spaces and must being with a letter. The name also can't
be ambiguous in terms of being a cell reference (you can't create a name
like A10 for example, or R1 or C5).

If it is mostly working, I suspect the value in the cell is not a legal
name.

--
Regards,
Tom Ogilvy

"fifthhorseman " wrote in
message ...
Hi,

I am working on some code that will look at each row (starting at row
2) and define the row by the value that is on the row in column 1,
until the program gets to a cell that is blank, in which the loop
stops. Everything seems to be working except for one small part. I
keep on getting Run-time error 1004: That Name is not valid.

The following is my code:

Private Sub cmdCatAddSyn_Click()
'Synchronize all pages with the new category
'IN PROGRESS

RCount = 2
Do Until Worksheets(1).Cells(RCount, 1).Value = ""
Worksheets(1).Rows(RCount).Name = Worksheets(1).Cells(RCount, 1)
RCount = RCount + 1
Loop
End Sub

The section of code that is always highlighted is
Worksheets(1).Rows(RCount).Name=Worksheets(1).Cell s(RCount,1)

All help is appreciated, and thank you in advance.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com