Results 1 to 6 of 6

application defined or object defined error

Threaded View

  1. #1
    Registered User
    Join Date
    01-17-2010
    Location
    israel
    MS-Off Ver
    Excel 2007
    Posts
    3

    application defined or object defined error

    Hi,

    i have this code that i wrote in excel 2007
    its work exelent but when i am trying to run the script in excel 2003 i got an error 1004
    applocation defined or object defined error
    this code change the datavalidation list dynamicly depands on a value in a cell

    i hope that you can help me

    shay

    
    Private Sub Worksheet_Change(ByVal Target As Range)
    
        If Target.Address = "$C$66" Then
            If Range("CompBranch") = "áçø òðó" Or Range("CompBranch") = "" Then
                Range("CompSubBranch").Select
                Sheet1.Unprotect Password:="veryfunny!"
                With Selection.Validation
                .Delete
                .Add Type:=xlValidateInputOnly, AlertStyle:=xlValidAlertStop, Operator _
                :=xlBetween
                End With
                Sheet1.Protect Password:="veryfunny!"
                Range("CompSubBranch") = Empty
                Exit Sub
            End If
            Call GenerateSubBranchList
            Range("CompSubBranch") = "áçø úú òðó"
        End If
            
    End Sub
    
    Sub GenerateSubBranchList()
        Dim rng As String
        rng = GetRange(Range("H66").Value)
        Range("CompSubBranch").Select
        Sheet1.Unprotect Password:="veryfunny!"
    
        With Selection.Validation
            .Delete
            .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
             xlBetween, Formula1:="='List'!" & rng
            .IgnoreBlank = True
            .InCellDropdown = True
            .InputTitle = ""
            .ErrorTitle = ""
            .InputMessage = ""
            .ErrorMessage = ""
            .ShowInput = True
            .ShowError = True
        End With    
        Sheet1.Protect Password:="veryfunny!"    
    End Sub
    
    Function GetRange(val As Integer) As String
       Dim startPnt As Integer 
       Dim endPnt As Integer
       For Each Item In Range("'List'!Q2:Q200")
        If Item.Value = val And startPnt = Empty Then startPnt = Item.Row
        If Item.Value = (val + 1) And endPnt = Empty Or Item.Value = Empty And endPnt =Empty Then endPnt = Item.Row - 1
      Next
       GetRange = "$P" & startPnt & ":$P" & endPnt
    End Function
    Last edited by SMazoz; 01-17-2010 at 06:10 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1