+ Reply to Thread
Results 1 to 6 of 6

macro driving me crazy

  1. #1
    Registered User
    Join Date
    03-11-2005
    Posts
    87

    macro driving me crazy

    I have the following code that at times gets the "error13 type mismatch message" when I open the sheet

    Private Sub Worksheet_Calculate()

    If Range("O15") <> "" Then
    If Range("Q17").Value = "yes" Then
    Range("O19") = Range("O15")
    Range("O20") = Range("q20")
    Range("P19") = Now
    End If
    End If

    If Range("Q25").Value = "yes" Then
    Range("O19") = ""
    Range("O20") = ""
    Range("P19") = ""
    End If


    End Sub


    As a result Excel gets into debugging mode at the first line of the code. Today it looks it makes not work the Sub_auto Open in one of the sheets. Anyone any idea what is going on????!!

    Cheeers
    BC

  2. #2
    Registered User
    Join Date
    10-25-2004
    Posts
    88
    Try IF IsEmpty(Range("O15")) Then ...
    Do you still get the error?

  3. #3
    Registered User
    Join Date
    03-11-2005
    Posts
    87
    the debugging error is now at the code line...

    If Range("Q25").Value = "yes" Then


    the first line now looks ok. how can i change it in a similar way?

    Many thanks!

  4. #4
    Registered User
    Join Date
    03-11-2005
    Posts
    87
    with the change suggested shouldnt anyway be something like...


    Private Sub Worksheet_Calculate()

    If IsEmpty(Range("O15")) Then Exit Sub
    If Range("Q17").Value = "yes" Then
    Range("O19") = Range("O15")
    Range("O20") = Range("Q20")
    Range("P19") = Now
    End If
    If Range("Q25").Value = "yes" Then
    Range("O19") = ""
    Range("O20") = ""
    Range("P19") = ""
    End If


    End Sub

    - do i have to add an instruction after the first code line to say that if is not empty then line 2 etc...
    -how i can express ((If Range("Q25").Value = "yes" Then)) in a different way as it still set me into debugging mode?

    thanks
    BC

  5. #5
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187
    I have not tested it but I think you would resolve the problem if you substituted .value for .text

  6. #6
    Registered User
    Join Date
    03-11-2005
    Posts
    87
    done and works!!
    thanks a lot
    BC

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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