"Unable to set the LineStyle property of the border class"

G

Guest

In Excel 2003 I have the following code:

For i = 2 1000 Step 2
Range(i + 1 & ":" & i + 1).Borders(xlEdgeBottom).LineStyle =
xlDouble
Next i

This code fails with the error "Unable to set the LineStyle property of the
border class" for i = 30 and i=128. It works for all the other lines.

Can anyone help me figure out what is going on?

Thanks
 
G

Guest

I should have mentioned that after deleting line 30 and 31 it failed only
when i=126 (was 128 before deletion). I have also found that if I right
click on a failing line and select "Format Cells" I get no format menu (or
any other response). Hmm - Now it doesn't seem as if it is a VBA problem.

Also, the For statement was : For i = 2 To 1000 Step 2
 
D

Dave Peterson

Can you change the bottom edge for rows 31 and 129 manually?

Ps. I'd use:

For i = 2 TO 1000 Step 2
rows(i + 1).Borders(xlEdgeBottom).LineStyle = xlDouble
Next i

(Maybe even go from 3 to 1001 and use plain old i in that rows(i) portion.)
 
G

Guest

No - If I right click on those lines or on any cell in those lines and
select "format Cells" I do not get the format dialog. Nothing happens at
all. If I click on any other line or cell all is normal.
 
D

Dave Peterson

Then it's not your code that is the cause of the problem.

My first guess is that you have merged cells in those rows. Do you?

They're miserable to work with manually and even more miserable in code.

This is just a guess, though. I blame all funny errors on merged cells!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top