Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50273

Run Time Error

$
0
0
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??

Code:

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


Viewing all articles
Browse latest Browse all 50273

Latest Images

Trending Articles



Latest Images