View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Applying style to row, getting Run-time error '450'

I only created one style, SubSection - 6.

Then this worked for me:

Sub Tester1()
Dim rngRow As Range, strStyle As String
Dim cell As Range
Set rngRow = Range("A10:I10")
Cells(rngRow.Row, 256).Value = "SubSection - "
strStyle = Cells(rngRow.Row, 256).Value
For Each cell In rngRow
If cell.Column = 6 Then
cell.Style = strStyle & cell.Column
End If
Next cell

End Sub
--
Regards,
Tom Ogilvy


"Dustin Carter" wrote in message
...
I'm attempting to apply a style to a row in Excel 2000 based on a

validated
cell at the end of the row (containing the style type). My clunky method

for
doing so, at this point, involves:

- having a style for each column in the row, for example:
"SubSection - 1"
"SubSection - 2"
"SubSection - 3"
- getting the data out of the validated cell
- setting the desired row as a range
- looping through each cell and applying the style type ("SubSection - ")
plus the column number as the style.

This is probably inefficient, but the real problem I'm encountering at

this
point is with the last step. The code is as follows:

For Each cell In rngRow
cell.Style = strStyle & cell.Column
Next cell

Seems simple, seems like it should work, but produces a Run-time error
'450'. No idea why, no idea how to fix it. Hopefully one of the great

Excel
Programming minds holds the answer...

Thanks,
Dustin Carter