PDA

View Full Version : Type Mismatch?



next
02-26-2008, 08:45 AM
Option Explicit
Public x As Range
Public agesumCWI As Worksheet, agesumCLS As Worksheet
Sub Test2()
Set agesumCWI = Workbooks("agesum.dif").Worksheets("Cleanway")
Set agesumCLS = Workbooks("agesum.dif").Worksheets("Licensing")

With agesumCWI
LastCell = .Range("B1").End(xlDown).Row

For Each x In Columns(13)
'exit if last cell is passed
If x.Value = 0 Then
x.EntireRow.Delete Shift:=xlUp
ElseIf x.Row > LastCell Then Exit For
'fill blank cells with "NET 30" value
If IsEmpty(x.Value) Then x.Value = "NET 30"
End If
Next x
End With
End Sub


This line is returning an error "Type Mismatch" for some reason:
If x.Value = 0 Then

The only thing that i'm trying to do is: if a cell value is 0 then delete entire row.

Bob Phillips
02-26-2008, 09:08 AM
Tell me, how do you manage to have Option Explicit, yet still not declare variables?



Public x As Range
Public agesumCWI As Worksheet, agesumCLS As Worksheet
Sub Test2()
Set agesumCWI = Workbooks("agesum.dif").Worksheets("Cleanway")
Set agesumCLS = Workbooks("agesum.dif").Worksheets("Licensing")

With agesumCWI
LastCell = .Range("B1").End(xlDown).Row

For Each x In Columns(13).Cells
'exit if last cell is passed
If x.Value = 0 Then
x.EntireRow.Delete Shift:=xlUp
ElseIf x.Row > LastCell Then Exit For
'fill blank cells with "NET 30" value
If IsEmpty(x.Value) Then x.Value = "NET 30"
End If
Next x
End With
End Sub

next
02-26-2008, 09:20 AM
Lol, i had it declared in my "full" Macro.
Thanks, it's working now.