Forum

Deleting rows if ce...
 
Notifications
Clear all

Deleting rows if certain cells in the row are 0

20 Posts
6 Users
0 Reactions
1,424 Views
(@purfleet)
Posts: 412
Reputable Member
 

it looks like you have the worksheets protected so the macro cant delete anything.

you can get the macro to unprotect the work sheet by adding activesheet.unprotect "summerscales" to the beginning of the macro (just after 'Sub DeleteRow()') and then turning it back on with  activesheet.protect "summerscales" just before exit sub

 
Posted : 25/01/2020 7:18 am
(@shina67)
Posts: 15
Active Member
 

Thanks for your reply Purfleet.

I have the code working correctly as a standalone bit of code. My problem is I need it to run within my code that's already there in the 'Inventory Booked Out' sheet.

When I insert it into there I then experience problems with it. 

 
Posted : 25/01/2020 3:52 pm
(@purfleet)
Posts: 412
Reputable Member
 

How are you putting the DeleteRow Sub in the existing ? are you pasting the whole code into a certain part of your existing code??

I noticed that you had the DeleteRow Sub code in module5, so i added a call DeleteRow at LN11 in the code on Sheet4 and apart from Inventory Booked in being protected seem to run okay (not checked output)

 

Private Sub Worksheet_Change(ByVal Target As Range)

'Unprotect Workbook
Sheets("Inventory Booked Out").Unprotect Password:="summerscales"
Sheets("Inventory Booked In").Unprotect Password:="summerscales"
Sheets("Scans with Date Time Stamp").Unprotect Password:="summerscales"
Sheets("Inventory List").Unprotect Password:="summerscales"

Call DeleteRow

Dim Item As String
Dim strDscrpt As String
Dim strPrice As String
Dim SearchRange As Range
Dim rFound As Range
Dim strBC As String

 
Posted : 25/01/2020 5:43 pm
(@shina67)
Posts: 15
Active Member
 

Thanks Purfleet for your reply and pointing out the obvious to me that I had stupidly missed. 

I didn't have 'Inventory Booked In' unprotected. Once I had included that all worked fine in how I already had it set to call DeleteRow.

 
Posted : 28/01/2020 1:20 am
(@purfleet)
Posts: 412
Reputable Member
 

Hi Sean 

Glad it is working - i have found with vba that it is often the most simple things that cause the code to break - i once spent an hour trying to get xlcentre to work only to realise that vba needs the US spelling of Centre, changed to xlcenter and it worked.

Still kicking myself for that one!

Purfleet

 
Posted : 28/01/2020 3:32 am
Page 2 / 2
Share: