Results 1 to 3 of 3

Run Time Error

Threaded View

  1. #1
    Registered User
    Join Date
    12-05-2012
    Location
    victoria
    MS-Off Ver
    Excel 2010
    Posts
    55

    Run Time Error

    Hey guys,

    In the code below, the line that says Z=... gives me a runtime error 13, type mismatch but if I switch the Z to R in that line and the one below then it works. why is that since Z and R are both integers??

    Sub proTest()
    
            Sheets("Sheet1").Select
            Range("B1").Select
            Dim R, a As Integer
            Dim Z As Integer
            
            Selection.Offset(0, 1).Value = Selection.Column
            
                    
            Do Until Selection.Value = ""
            a = 0
            R = 4
            Z = 0
            Do Until Selection.Value = ""
                    If Selection.Column = 2 Then
                     Z = "=countif(B:B,"">"" & " & Selection.Value & ")"
                    Selection.Offset(0, -1).Value = Z
                    
                    
                    
                    Else
                    S = "=countif(D:D,"">"" & " & Selection.Value & ")"
                    End If
                    
                    
                    Selection.Offset(0, 1).Value = "=COUNTIF(B:B,"">"" & " & Selection.Value & ")+ COUNTIF(D:D,"">"" & " & Selection.Value & ")+ COUNTIF(F:F,"">"" & " & Selection.Value & ")"
                    
                                                    
                                    
                    Selection.Offset(1, 0).Select
                    a = a + 1
            Loop
    
            Selection.Offset(-a, 2).Select
            R = R + 2
            Loop
            
    
    
    End Sub
    Last edited by arlu1201; 12-06-2012 at 02:54 PM. Reason: Corrected code tags.

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