Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default macro crashes excell xp

Hi,

I am using this macro to bold all my locked cells and it
crashes Excel unless I restrict its range to very small
areas. I would like to let it run through the entire
workbook. Can someone help me clean up the code so it
does not crash?


Thanks,


Todd




Sub BoldLocked()
For Each cell In Selection.Cells
If cell.Locked = True Then
cell.Font.Bold = True
End If
If cell.Locked = False Then
cell.Font.Bold = False
End If
Next cell
MsgBox "No more cells to check"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default macro crashes excell xp

Well, here is what I would do to clean up the code:

For Each Cell In Selection.Cells
Cell.Font.Bold = Cell.Locked
Next Cell
MsgBox "No more cells to check"

I am not sure why it is crashing with this
code...remember that a valid selection needs to exist, so
some error handling is warranted (what if a chart is
selected?).

Hope this helps.

Seth

-----Original Message-----
Hi,

I am using this macro to bold all my locked cells and it
crashes Excel unless I restrict its range to very small
areas. I would like to let it run through the entire
workbook. Can someone help me clean up the code so it
does not crash?


Thanks,


Todd




Sub BoldLocked()
For Each cell In Selection.Cells
If cell.Locked = True Then
cell.Font.Bold = True
End If
If cell.Locked = False Then
cell.Font.Bold = False
End If
Next cell
MsgBox "No more cells to check"
End Sub
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default macro crashes excell xp

You might like this better.

Sub lockbold()
Application.ScreenUpdating = False
Application.Calculation = xlManual
For Each ws In Sheets
For Each cell In ws.UsedRange
If cell.Locked = True Then cell.Font.Bold = True
Next cell
Next ws
Application.ScreenUpdating = True
Application.Calculation = xlAutomatic
MsgBox "No more cells to check"
End Sub

"Todd" wrote in message
...
Hi,

I am using this macro to bold all my locked cells and it
crashes Excel unless I restrict its range to very small
areas. I would like to let it run through the entire
workbook. Can someone help me clean up the code so it
does not crash?


Thanks,


Todd




Sub BoldLocked()
For Each cell In Selection.Cells
If cell.Locked = True Then
cell.Font.Bold = True
End If
If cell.Locked = False Then
cell.Font.Bold = False
End If
Next cell
MsgBox "No more cells to check"
End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Excell 03/07 Mike Excel Discussion (Misc queries) 2 January 5th 10 01:13 AM
Macro options in Excell 2003 Joshua Excel Worksheet Functions 1 April 30th 08 07:16 PM
Excell Macro Help Please Bill Kirk New Users to Excel 2 January 25th 06 09:22 PM
converting Lotus 123 macro to Excell macro mark h Excel Discussion (Misc queries) 6 July 11th 05 01:28 PM
Macro Text into Excell Krefty Excel Discussion (Misc queries) 2 December 20th 04 09:14 PM


All times are GMT +1. The time now is 07:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"