I have a workbook, that several people are entering data in on a daily basis. They enter data on a worksheet, hit a macro enabled button and it saves the data on a separate hidden worksheet. I have another worksheet that totals scores, but when the data stored in the data sheet, the named range changes as rows are inserted. I have a line in my macro that changes the reference back every time the macro runs. It worked great until this year. I saved the file as a new name....deleted old data, everything works fine except it doesn't change my references back anymore. If I had created this workbook, I would have done things a bit different.....but anyway.......
There are no external connections, the named range is in the current workbook, when the code runs it does not stop, but it does not change the reference. Any thoughts?
Sub recordinspection()
'
' Save Inspection Record Macro
'
'
If Sheets("Monthly Inspection").Range("A6").Value <> "" And Sheets("Monthly Inspection").Range("B6").Value <> "" And Sheets("Monthly Inspection").Range("C6").Value <> "" Then GoTo 2
MsgBox ("Please Enter Complete Date")
Exit Sub
2 If Sheets("Monthly Inspection").Range("B66").Value <> "" Then GoTo 3
MsgBox ("Please Enter Supervisor")
Exit Sub
3 If Sheets("Monthly Inspection").Range("B68").Value <> "" Then GoTo 4
MsgBox ("Please Enter Zone")
Exit Sub
4 If Sheets("Monthly Inspection").Range("B70").Value <> "" Then GoTo 5
MsgBox ("Please Enter Description")
Exit Sub
5 Sheets("Data3").Visible = True
Sheets("Data3").Select
ActiveSheet.unprotect "Atlantic"
Rows("7:7").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A7:H7").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlThin
End With
Range("A6").Select
Sheets("Monthly Inspection").Select
ActiveWindow.SmallScroll ToRight:=6
Range("I6:O6").Select
Selection.Copy
Sheets("Data3").Select
Range("B7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Monthly Inspection").Select
Range("I3").Select
Selection.Copy
Sheets("Data3").Select
Range("A7").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("A6").Select
Sheets("Monthly Inspection").Select
Range("A6:C6").Select
Selection.ClearContents
Range("B66").Select
Selection.ClearContents
Range("B68").Select
Selection.ClearContents
Range("B70:E72").Select
Selection.ClearContents
ActiveWorkbook.Names("Plagesuivi11").RefersToR1C1 = "=Data3!R7C2:R2000C2"
ActiveWorkbook.Names("Plagesuivi12").RefersToR1C1 = "=Data3!R7C6:R2000C6"
Sheets("Data3").Select
ActiveSheet.Protect "Atlantic"
Sheets("Data3").Visible = False
ActiveWorkbook.Save
End Sub
Bookmarks