Code doesn't work consistently

LC1234

New Member
Joined
Nov 10, 2005
Messages
12
Can someone tell me why this doesn't work the same way everytime? It's supposed to go to a certian range and "turn off" the top & bottom lines. Sometimes it works and sometimes it doesn't. What am I missing? (There is a bunch of code after this that works fine, so I've taken it out.)
Learning on my own, so sorry if this is really simple!

Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveSheet.Unprotect Password:="hockey"
Const Spdsht = "B6:V863"
Const MetricNames = "B6:B864"
Const LastLine = "B864:V864"
Const TitleLine = "B4:V4"

Set DC = Range("K1")
Set Index = Range("J1")
Set MetricWanted = Range("P1")
Set Index2 = Range("O1")

Range("E5").Select
Selection.EntireRow.Hidden = False

Range(Spdsht).Select 'remove top & bottom lines
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

How many sheets are there in the workbook? If there is more than one, is it possible that you are on a different sheet from the one that needs the lines removed???


Tony
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,111
Messages
5,835,444
Members
430,356
Latest member
RadStorm20

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top