user3432879
user3432879

Reputation: 11

Run-time error '1004': Unable to set line style property of border class in VBA

Run-time error '1004': Unable to set line style property of border class in VBA.

while running code for setting the border of range then getting run time error and same code is running successfully on different system.

The code is:

Range("A7:A" & LastRow).Borders.LineStyle = xlContinuous

Could you please help?

Upvotes: 0

Views: 4435

Answers (2)

Thirupathi Reddy
Thirupathi Reddy

Reputation: 31

I have faced similar issue many times. All the times the only problem was i needed to unlock the sheet.

Can you check if your worksheets are protected or if your workbook is protected? In that case you need to unlock the Worksheet/Workbook for your code to function properly.

Upvotes: 2

Vityata
Vityata

Reputation: 43575

Try like this:

Activesheet.Range("A7:A" & LastRow).Borders.LineStyle = xlContinuous

The error probably comes because you are not referring the WorkSheet of the range or because the worksheet is locked.

Upvotes: 0

Related Questions