Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Code Run-time Error '13

Hello all, I'm having problems with the code below. The purpose of
the code is to check column A cell content for "Delete" which is
populated by a vlookup formula. The problem is if an account is not
found then the cell is populated with #N/A and causes a run-time error
'13: type mismatch. Any ideas on correcting this? Appreciate your
assistance, Ron


Sub DeleteSTBAccounts()
Dim RowNdx As Long
Dim LastRow As Long

application.ScreenUpdating = False
ActiveSheet.Rows.Hidden = False


LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A") = "Delete" Then
Rows(RowNdx).EntireRow.Delete
End If

Next RowNdx
range("A1").Select
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default Code Run-time Error '13

It might not like the redundancy in this line:

Rows(RowNdx).EntireRow.Delete

try:


Rows(RowNdx).Delete



"Ron" wrote in message
...
Hello all, I'm having problems with the code below. The purpose of
the code is to check column A cell content for "Delete" which is
populated by a vlookup formula. The problem is if an account is not
found then the cell is populated with #N/A and causes a run-time error
'13: type mismatch. Any ideas on correcting this? Appreciate your
assistance, Ron


Sub DeleteSTBAccounts()
Dim RowNdx As Long
Dim LastRow As Long

application.ScreenUpdating = False
ActiveSheet.Rows.Hidden = False


LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


For RowNdx = LastRow To 1 Step -1
If Cells(RowNdx, "A") = "Delete" Then
Rows(RowNdx).EntireRow.Delete
End If

Next RowNdx
range("A1").Select
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Code Run-time Error '13

Hi JLGWhiz, the error is coming on this line.... If Cells(RowNdx,
"A") = "Delete" Then. I made the suggested change, but still got the
error. Thanks, Ron


On Aug 21, 1:49*pm, "JLGWhiz" wrote:
It might not like the redundancy in this line:

Rows(RowNdx).EntireRow.Delete

try:

Rows(RowNdx).Delete

"Ron" wrote in message

...



Hello all, *I'm having problems with the code below. *The purpose of
the code is to check column A cell content for "Delete" which is
populated by a vlookup formula. *The problem is if an account is not
found then the cell is populated with #N/A and causes a run-time error
'13: type mismatch. *Any ideas on correcting this? *Appreciate your
assistance, Ron


Sub DeleteSTBAccounts()
Dim RowNdx As Long
Dim LastRow As Long


application.ScreenUpdating = False
ActiveSheet.Rows.Hidden = False


LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


For RowNdx = LastRow To 1 Step -1
* * * *If Cells(RowNdx, "A") = "Delete" Then
* * * * * *Rows(RowNdx).EntireRow.Delete
* * * *End If


Next RowNdx
range("A1").Select
End Sub- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Code Run-time Error '13

Hi Stan, worked perfect. Thank you for your assistance, Ron




On Aug 21, 2:04*pm, Ron wrote:
Hi JLGWhiz, *the error is coming on this line.... If Cells(RowNdx,
"A") = "Delete" Then. *I made the suggested change, but still got the
error. *Thanks, Ron

On Aug 21, 1:49*pm, "JLGWhiz" wrote:



It might not like the redundancy in this line:


Rows(RowNdx).EntireRow.Delete


try:


Rows(RowNdx).Delete


"Ron" wrote in message


...


Hello all, *I'm having problems with the code below. *The purpose of
the code is to check column A cell content for "Delete" which is
populated by a vlookup formula. *The problem is if an account is not
found then the cell is populated with #N/A and causes a run-time error
'13: type mismatch. *Any ideas on correcting this? *Appreciate your
assistance, Ron


Sub DeleteSTBAccounts()
Dim RowNdx As Long
Dim LastRow As Long


application.ScreenUpdating = False
ActiveSheet.Rows.Hidden = False


LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row


For RowNdx = LastRow To 1 Step -1
* * * *If Cells(RowNdx, "A") = "Delete" Then
* * * * * *Rows(RowNdx).EntireRow.Delete
* * * *End If


Next RowNdx
range("A1").Select
End Sub- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code Run-time Error '13


Ron,

Try:


Code:
--------------------


Option Explicit
Sub DeleteSTBAccounts()
Dim RowNdx As Long
Dim LastRow As Long
Application.ScreenUpdating = False
ActiveSheet.Rows.Hidden = False
LastRow = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
For RowNdx = LastRow To 1 Step -1
If IsError(Cells(RowNdx, "A")) Then
'Do nothing
ElseIf Cells(RowNdx, "A") = "Delete" Then
Rows(RowNdx).EntireRow.Delete
End If
Next RowNdx
Range("A1").Select
End Sub


--------------------



Have a great day,
Stan


--
stanleydgromjr
------------------------------------------------------------------------
stanleydgromjr's Profile: http://www.thecodecage.com/forumz/member.php?userid=503
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=127581



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting Run-time error although code looks correct robs3131 Excel Programming 6 May 28th 07 11:15 AM
Problem w/ Code- Error 91 @ run-time dailem Excel Programming 1 August 25th 06 07:29 PM
Run-time error '9' ---- Code to fix included. [email protected] Excel Programming 3 September 2nd 05 02:48 PM
Run-time error from my code Matt Excel Programming 5 June 24th 04 03:32 AM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim[_36_] Excel Programming 4 April 23rd 04 02:53 AM


All times are GMT +1. The time now is 12:09 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"