Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error 1004 when running on a protected sheet

I am new to vb code and would like help with the following problem.

I am running the following code in a multipage spreadsheet. Columns 5
8 and 11 should be the only unprotected columns in the six sheets i
question. Based upon a formula in columns 6, 9 and 12 of sheets 1 thr
6 and a value in sheet 7 those columns (6,9,12) are set to an "X" valu
or "RANK"ed base upon the values in 5, 8 and 11. Note: some values i
columns and 5 and 6 are null value. This formula works and modifys th
correct cells in columns 6, 9 and 12. The desired effect of the VB cod
below is to increment/decrement cells in formula selected rows by 100
to so the rank instruction will work properly.

All seems to work ok unless I turn protection on in any of the si
pages. I then receive an error 1004 on the instruction below.

For Each cell In Columns(6).SpecialCells(3) - This is the sixth lin
of code below.

This is the first VB code I have tried to use and any and all hel
would be appreciated. I am running excel 2000 (9.0 3821 SR-1)

I realize this is confusing and I can email entire spreadsheet t
anyone that might have an idea.

Thanks in advance for the help.

Private Sub Worksheet_Calculate()
With Application
.ScreenUpdating = False
ActiveSheet.Unprotect
Dim cell As Range
For Each cell In Columns(6).SpecialCells(3)
If cell.Value = "x" Then
.EnableEvents = False
If cell.Offset(0, -1).Value < 1000 Then
cell.Offset(0, -1).Value = cell.Offset(0, -1).Value + 1000
.EnableEvents = True
End If
Else
If cell.Value < "" And cell.Offset(0, -1).Value 1000 Then
.EnableEvents = False
cell.Offset(0, -1).Value = cell.Offset(0, -1).Value - 1000
.EnableEvents = True
End If
.EnableEvents = True
End If
Next cell

For Each cell In Columns(9).SpecialCells(3)
If cell.Value = "x" Then
.EnableEvents = False
If cell.Offset(0, -1).Value < 1000 Then
cell.Offset(0, -1).Value = cell.Offset(0, -1).Value + 1000
.EnableEvents = True
End If
Else
If cell.Value < "" And cell.Offset(0, -1).Value 1000 Then
.EnableEvents = False
cell.Offset(0, -1).Value = cell.Offset(0, -1).Value - 1000
.EnableEvents = True
End If
.EnableEvents = True
End If
Next cell

For Each cell In Columns(12).SpecialCells(3)
If cell.Value = "x" Then
.EnableEvents = False
If cell.Offset(0, -1).Value < 1000 Then
cell.Offset(0, -1).Value = cell.Offset(0, -1).Value + 1000
.EnableEvents = True
End If
Else
If cell.Value < "" And cell.Offset(0, -1).Value 1000 Then
.EnableEvents = False
cell.Offset(0, -1).Value = cell.Offset(0, -1).Value - 1000
.EnableEvents = True
End If
.EnableEvents = True
End If
Next cell
ActiveSheet.Protect
.ScreenUpdating = True
End With
End Su

--
Message posted from http://www.ExcelForum.com

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
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
Run time error 1004 When running in 2003 Lakshman Excel Discussion (Misc queries) 10 January 17th 07 06:06 PM
Run Time error '1004' when running Calculation method Simon P[_2_] Excel Programming 1 January 5th 04 12:32 PM
Run-time error '1004' running to excel objects at once Dianna Braden Excel Programming 0 October 16th 03 08:55 PM


All times are GMT +1. The time now is 08:24 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"