PC Review


Reply
Thread Tools Rate Thread

Code Run-time Error '13

 
 
Ron
Guest
Posts: n/a
 
      21st Aug 2009
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
 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      21st Aug 2009
It might not like the redundancy in this line:

Rows(RowNdx).EntireRow.Delete

try:


Rows(RowNdx).Delete



"Ron" <(E-Mail Removed)> wrote in message
news:bfcf572d-e24f-4601-9604-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Ron
Guest
Posts: n/a
 
      21st Aug 2009
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" <JLGW...@cfl.rr.com> wrote:
> It might not like the redundancy in this line:
>
> Rows(RowNdx).EntireRow.Delete
>
> try:
>
> Rows(RowNdx).Delete
>
> "Ron" <whasupwit...@verizon.net> wrote in message
>
> news:bfcf572d-e24f-4601-9604-(E-Mail Removed)...
>
>
>
> > 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 -


 
Reply With Quote
 
Ron
Guest
Posts: n/a
 
      21st Aug 2009
Hi Stan, worked perfect. Thank you for your assistance, Ron




On Aug 21, 2:04*pm, Ron <whasupwit...@verizon.net> 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" <JLGW...@cfl.rr.com> wrote:
>
>
>
> > It might not like the redundancy in this line:

>
> > Rows(RowNdx).EntireRow.Delete

>
> > try:

>
> > Rows(RowNdx).Delete

>
> > "Ron" <whasupwit...@verizon.net> wrote in message

>
> >news:bfcf572d-e24f-4601-9604-(E-Mail Removed)...

>
> > > Hello all, *I'm having problems with the code below. *The purposeof
> > > 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 -


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
run time error '424' when I run this code =?Utf-8?B?cmF2aQ==?= Microsoft Excel Programming 6 8th Aug 2005 10:21 PM
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) Tim Microsoft Excel Programming 4 23rd Apr 2004 02:53 AM
error using code second time Kees Microsoft Access External Data 2 19th Jan 2004 06:03 AM
Time Code Error Craig Ducote Windows XP General 2 12th Nov 2003 11:31 PM
RUN TIME ERROR CODE ETPLUS5 Windows XP General 0 1st Sep 2003 05:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:21 AM.