LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Protection nightmare

Can anyone help me please?

The following is my code which compares cell data and
does various operations, it is quite complicated.

My problem is basically that when someone enters
deliveries in the relevant cells and the macro is run,
those cells become protected but were not before.

Can anyone see in the code anything that causes this to
happen?

Cheers

Joe

'First job is to carry forward bookstocks
Sheets("BOOKSTOCK").Select
'Top section left to right
For z = 4 To 24 Step 2

'Dim first As String
'Chooses stock b/f serial code
For a = 7 To 17 Step 2
Cells(a, z).Select
'first = ActiveCell

'Chooses stock used serial code and compares to stock
b/f
'If same then takes closing no up to stock b/f
For b = 25 To 27 Step 2
Cells(b, z).Select
'If ActiveCell = first Then
If Cells(b, z) = Cells(a, z) Then
Cells(b, z + 1).Select: Selection.Copy: Cells(a +
1, z + 1).Select: Selection.PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
End If
Next b

Next a

'Dim second As String
'Chooses deliveries stock serial code
For c = 19 To 23 Step 2
Cells(c, z).Select
'second = ActiveCell

'Chooses stock used serial code and compares to stock
deliveries
'If same then takes closing no to deliveries
For d = 25 To 27 Step 2
Cells(d, z).Select
'If ActiveCell = second Then
If Cells(d, z) = Cells(c, z) Then
Cells(d, z + 1).Select: Selection.Copy: Cells(c +
1, z + 1).Select: Selection.PasteSpecial
Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False
End If
Next d

Next c

'Compares stock b/f code no's and if same deletes
'For f = 5 To 10 Step 2
For e = 34 To 44 Step 2
Cells(e, z + 1).Select
If ActiveCell = 0 Then
Cells(e - 27, z).Select: Selection.ClearContents
Cells(e - 27, z + 1).Select:
Selection.ClearContents
Cells(e - 26, z + 1).Select:
Selection.ClearContents
End If
Next e
'Next f

'Compares deliveries code no's and if same deletes
'For g = 5 To 10 Step 2
For h = 46 To 50 Step 2
Cells(h, z + 1).Select
If ActiveCell = 0 Then
Cells(h - 27, z).Select: Selection.ClearContents
Cells(h - 27, z + 1).Select:
Selection.ClearContents
Cells(h - 26, z + 1).Select:
Selection.ClearContents
End If
Next h
'Next g

'Copies serial code into second line
For i = 7 To 23 Step 2
Cells(i, z).Select
Selection.Copy
Cells(i + 1, z).Select
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks:=False, Transpose:=False
Next i

'Sorts stock
Range(Cells(7, z), Cells(24, z + 1)).Select
Selection.sort Key1:=Cells(7, z),
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

'Clears second line of serial code
For j = 7 To 17 Step 2
Cells(j + 1, z).Select
Selection.ClearContents
Next j

'Range("D8").Select
'Selection.ClearContents

'Makes stock b/f section white
Range(Cells(7, z), Cells(18, z + 1)).Select
With Selection.Interior
.ColorIndex = 2
.Pattern = xlSolid
End With

'Makes deliveries section yelow
Range(Cells(19, z), Cells(24, z + 1)).Select
Selection.ClearContents
With Selection.Interior
.ColorIndex = 6
.Pattern = xlSolid
End With

'Clears serial codes in used section
Range(Cells(25, z), Cells(28, z)).Select
Selection.ClearContents

'Clears unwanted stray figures
For k = 7 To 17 Step 2
Cells(k, z + 1).Select
If ActiveCell = "" Then
'Cells(k + 1, z + 1).Select:
Selection.ClearContents
Range(Cells(k, z + 1), Cells(k + 1, z + 1)).Select
Selection.ClearContents
End If
Next k


Next z




 
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
nightmare formula [email protected] Excel Worksheet Functions 4 March 15th 09 10:36 AM
PivotTable Nightmare Sandi Excel Discussion (Misc queries) 3 March 3rd 07 04:34 PM
Concatenate Nightmare! DEE Excel Worksheet Functions 10 November 16th 06 12:00 AM
PivotTable Nightmare MarkM Excel Discussion (Misc queries) 1 August 14th 06 07:41 PM
VLookup Nightmare! twarden Excel Worksheet Functions 3 July 24th 06 11:46 PM


All times are GMT +1. The time now is 12:51 PM.

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

About Us

"It's about Microsoft Excel"