PC Review


Reply
Thread Tools Rate Thread

Delete row on another sheet same workbook problem

 
 
Les Stout
Guest
Posts: n/a
 
      31st Mar 2007
Hi all, i am using the code below and it is not working as i want it to,
could somebody please help me ??
When i want to run this i am in the sheet Recon and it counts the rows
in recon ??

Sub DeleteInvoice()
'
Dim i As Long, iLastRow As Long
Dim myInv As String
myInv = InputBox("PLease enter the number of the invoice to
delete...", "DELETE INVOICE", "024908")
With Sheets("Invoices")
iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If Cells(i, "A").Value = myInv Then
Rows(i).Delete
End If
Next i
End With
End Sub


Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Nick Hodge
Guest
Posts: n/a
 
      31st Mar 2007
Les

What is 'not as expected'. The structure of the code is a little wierd in
that your with...end with block refers to Sheets("Invoices"), but it does
nothing on that sheet if you are running this with another sheet active
(Recon??) as the Cells(....) references with all refer to recon. Perhaps
you meant to prefix all those references with a period (.) so it refers to
the Invoices sheet???

Sub DeleteInvoice()
'
Dim i As Long, iLastRow As Long
Dim myInv As String
myInv = InputBox("PLease enter the number of the invoice to
delete...", "DELETE INVOICE", "024908")
With Sheets("Invoices")
iLastRow = .Cells(Rows.Count, "A").End(xlUp).Row
For i = iLastRow To 1 Step -1
If .Cells(i, "A").Value = myInv Then
.Rows(i).Delete
End If
Next i
End With
End Sub

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
web: www.nickhodge.co.uk
blog: www.nickhodge.co.uk/blog/

FREE UK OFFICE USER GROUP MEETING, MS READING, 27th APRIL 2007
www.officeusergroup.co.uk

"Les Stout" <(E-Mail Removed)> wrote in message
>news:(E-Mail Removed)...
> Hi all, i am using the code below and it is not working as i want it to,
> could somebody please help me ??
> When i want to run this i am in the sheet Recon and it counts the rows
> in recon ??
>
> Sub DeleteInvoice()
> '
> Dim i As Long, iLastRow As Long
> Dim myInv As String
> myInv = InputBox("PLease enter the number of the invoice to
> delete...", "DELETE INVOICE", "024908")
> With Sheets("Invoices")
> iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
> For i = iLastRow To 1 Step -1
> If Cells(i, "A").Value = myInv Then
> Rows(i).Delete
> End If
> Next i
> End With
> End Sub
>
>
> Les Stout
>
> *** Sent via Developersdex http://www.developersdex.com ***


 
Reply With Quote
 
Susan
Guest
Posts: n/a
 
      31st Mar 2007
what's your specific error & where?
from what i can see, you might need to change this:

myInv = InputBox("PLease enter the number of the invoice to
delete...", "DELETE INVOICE", "024908").value <-----

but i might be wrong because i haven't worked with input boxes.

so you're counting the rows in RECON but you're deleting in INVOICES?
where's the variable being passed from RECON?

susan


On Mar 31, 8:49 am, Les Stout <anonym...@devdex.com> wrote:
> Hi all, i am using the code below and it is not working as i want it to,
> could somebody please help me ??
> When i want to run this i am in the sheet Recon and it counts the rows
> in recon ??
>
> Sub DeleteInvoice()
> '
> Dim i As Long, iLastRow As Long
> Dim myInv As String
> myInv = InputBox("PLease enter the number of the invoice to
> delete...", "DELETE INVOICE", "024908")
> With Sheets("Invoices")
> iLastRow = Cells(Rows.Count, "A").End(xlUp).Row
> For i = iLastRow To 1 Step -1
> If Cells(i, "A").Value = myInv Then
> Rows(i).Delete
> End If
> Next i
> End With
> End Sub
>
> Les Stout
>
> *** Sent via Developersdexhttp://www.developersdex.com***



 
Reply With Quote
 
Les Stout
Guest
Posts: n/a
 
      31st Mar 2007
100% thanks Nick, will get the hell of this one day !!!

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
Nick Hodge
Guest
Posts: n/a
 
      31st Mar 2007
I'm still waiting to get it ;-)

--
HTH
Nick Hodge
Microsoft MVP - Excel
Southampton, England
(E-Mail Removed)DTHIS
web: www.nickhodge.co.uk
blog: www.nickhodge.co.uk/blog/

FREE UK OFFICE USER GROUP MEETING, MS READING, 27th APRIL 2007
www.officeusergroup.co.uk

"Les Stout" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 100% thanks Nick, will get the hell of this one day !!!
>
> Les Stout
>
> *** Sent via Developersdex http://www.developersdex.com ***


 
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
Delete last sheet in workbook Joe Gieder Microsoft Excel Programming 13 21st May 2008 07:37 PM
delete sheet in shared workbook =?Utf-8?B?SmFhbg==?= Microsoft Excel Programming 6 24th Oct 2007 08:26 AM
Delete Row 1 from every sheet in a workbook EeOr Microsoft Excel Discussion 2 10th Apr 2007 11:29 AM
Delete all but 1 sheet in workbook cdclayton Microsoft Excel Programming 3 11th Apr 2006 10:47 PM
Re: Copy sheet from one workbook to another workbook problem Ron de Bruin Microsoft Excel Programming 3 5th Aug 2004 07:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:05 PM.