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: 50
Default NEED HELP - For run time error '1004'

Dear Friends,

I'm getting the run time error '1004' - Application defined or Object
defined and some times run time error '1104' - unable to set the locked
property for the range class.

i'm getting this error on the line 37.

here is my code. kindly help me at the earliest.

Workbook Open code:-

Dim I As Integer
Dim J As Integer
Dim LastLine As Integer
Private Sub Workbook_Open()

For I = 4 To 500
If Sheet6.Cells(I, 1).Value = "-" Then
LastLine = I
'MsgBox LastLine
Exit For
End If
Next I

Sheet6.Unprotect Password:="123"

Sheet6.Cells(1, 6).Value = Date
Sheet6.Range(Cells(1, 1), Cells(2, 256)).Locked = True

For I = 3 To LastLine - 1
Sheet6.Cells(I, 7).Locked = True
Next I

For I = 3 To LastLine - 1
For J = 9 To 38
Sheet6.Cells(I, J).Locked = True
Next J
Next I



For I = 3 To LastLine - 1
For J = 9 To 13
If Sheet6.Cells(I, 8).Value = "" Or Sheet6.Cells(I, 8).Value =
"NR" Then
Sheet6.Cells(I, J).Locked = True
Else
Sheet6.Cells(I, J).Locked = False
End If
Next J
Next I

For I = 4 To LastLine Step 2
Sheet6.Cells(I, 9).Locked = True
Sheet6.Cells(I, 10).Locked = True
Next I


Sheet6.Range(Cells(3, 39), Cells(LastLine, 256)).Locked = True
Sheet6.Range(Cells(LastLine, 1), Cells(65536, 256)).Locked = True

Sheet6.Protect Password:="123", AllowFiltering:=True

End Sub

Worksheet Change Code:-

Dim I As Integer
Dim Material As String
Dim Response As String
Dim Msg As String
Dim SiteName As String

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row Mod 2 = 0 Then
Material = "SHELTER"
SiteName = Cells(Target.Row - 1, 5).Value
Else
Material = "TOWER"
SiteName = Cells(Target.Row, 5).Value
End If

If Target.Column = 8 Then
Me.Unprotect Password:="123"
Select Case (Target)
Case "":
MsgBox "SORRY. YOU SHOULD ENTER EITHER REQ. / NR IN THIS
CELL.", vbCritical, "ERROR"
Case "NR":
Msg = "ARE YOU SURE " & SiteName & "'S " & Material & " IS
NOT REQUIRED?. IF YOU CLICK 'YES' THEN YOU CAN NOT CHANGE THE VALUES BACK
AGAIN."
Response = MsgBox(Msg, vbYesNo, "CONFIRM MATERIAL NOT
REQUIRED")
If Response = vbYes Then
For I = 9 To 38
Cells(Target.Row, I).Value = "NR"
Cells(Target.Row, I).Locked = True
Next I
Else
Target.Value = "REQ."
End If
Case "REQ.":
If Material = "TOWER" Then
Cells(Target.Row, 9).Locked = False
Cells(Target.Row, 9).Value = "-"
Cells(Target.Row, 13).Value = "ND"
Msg = "PLEASE ENTER THE TOWER TYPE."
MsgBox Msg, vbInformation, "ENTER TOWER TYPE"
Else
Cells(Target.Row, 11).Locked = False
Cells(Target.Row, 11).Value = "-"
Cells(Target.Row, 13).Value = "ND"
Msg = "PLEASE ENTER THE SHELTER SUPPLY VENDOR NAME."
MsgBox Msg, vbInformation, "ENTER SUPPLY VENDOR NAME"
End If
End Select
Me.Protect Password:="123", AllowFiltering:=True
End If

' If Target.Column = 9 Then
' Me.Unprotect Password:="123"
' Select Case (Target)
' Case "-":
' 'DO NOTHING
' Case "NR":
' If Cells(Target.Row, 8).Value = "REQ." Then
' Target.Value = "-"
' Cells(Target.Row, 10).Value = "-"
' End If
' Case "GBT", "RTT", "POLE", "DELTA":
' Cells(Target.Row, 10).Locked = False
' Cells(Target.Row, 10).Value = "-"
' Msg = "PLEASE ENTER THE TOWER HEIGHT."
' MsgBox Msg, vbInformation, "ENTER TOWER HEIGHT"
' Case Else:
' Target.Value = "-"
' Cells(Target.Row, 10).Value = "-"
' End Select
' Me.Protect Password:="123", AllowFiltering:=True
' End If
'
' If Target.Column = 10 Then
' Me.Unprotect Password:="123"
' If Cells(Target.Row, 9).Value = "-" And Target < "-" Then
' Msg = "PLEASE ENTER THE TOWER TYPE DATA FIRST."
' MsgBox Msg, vbInformation, "DATA UNACCEPTANCE"
' Target.Value = "-"
' Else
' Select Case (Target)
' Case "":
' Target.Value = "-"
' Msg = "PLEASE ENTER THE TOWER HEIGHT."
' MsgBox Msg, vbInformation, "ENTER TOWER HEIGHT"
' Case "-":
' 'DO NOTHING
' Case "NR":
' If Cells(Target.Row, 8).Value = "REQ." Then
' Target.Value = "-"
' Cells(Target.Row, 11).Value = "-"
' End If
' Case Is <= 21:
' If Cells(Target.Row, 9).Value = "GBT" Then
' Msg = "INVALID TOWER HEIGHT."
' MsgBox Msg, vbCritical, "INVALID DATA ENTRY"
' Target.Value = "-"
' Else
' Cells(Target.Row, 11).Value = "-"
' Cells(Target.Row, 11).Locked = False
' Msg = "PLEASE ENTER THE TOWER SUPPLY VENDOR NAME."
' MsgBox Msg, vbInformation, "ENTER SUPPLY VENDOR NAME"
' End If
' Case Is 21:
' If Cells(Target.Row, 9).Value < "GBT" Then
' Msg = "INVALID TOWER HEIGHT."
' MsgBox Msg, vbCritical, "INVALID DATA ENTRY"
' Target.Value = "-"
' Else
' Cells(Target.Row, 11).Value = "-"
' Cells(Target.Row, 11).Locked = False
' Msg = "PLEASE ENTER THE TOWER SUPPLY VENDOR NAME."
' MsgBox Msg, vbInformation, "ENTER SUPPLY VENDOR NAME"
' End If
' Case Else:
' Target.Value = "-"
' Cells(Target.Row, 11).Value = "-"
' End Select
' End If
' Me.Protect Password:="123", AllowFiltering:=True
' End If
'
' If Target.Column = 11 Then
' Me.Unprotect Password:="123"
' Select Case (Target)
' Case "-":
' 'DO NOTHING
' Case "", " ", "NA":
' Msg = "DON'T FORGET TO ENTER THE SUPPLY VENDOR NAME LATER."
' MsgBox Msg, vbInformation, "INFORMATION"
' Target.Value = "-"
' Case "NR":
' If Cells(Target.Row, 8).Value = "REQ." Then
' Target.Value = "-"
' End If
' Case Else:
' Cells(Target.Row, 12).Locked = False
' Cells(Target.Row, 12).Value = "-"
' Msg = "PLEASE ENTER THE ERECTION VENDOR NAME."
' MsgBox Msg, vbInformation, "ENTER ERECTION VENDOR NAME"
' End Select
' Me.Protect Password:="123", AllowFiltering:=True
' End If
End Sub

Thanks,
Sriram
 
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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


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

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"