Problems deleting row based on two adjacent cell values.

Dave

New Member
Joined
Mar 13, 2002
Messages
25
Hi All:

I'm using a set of forms to capture data, save it to dated workbook, and copy data to access97 using DAO. In order to not have null data in the database, I'm trying to delete rows if the values in adjacent cells C3 and D3 (C4 and D4...C6, D6) is 0. After a search of the board I found, and modified, this code (thanks Nimrod):

Option Explicit

Public Sub DelRowsbyCellValue()

Dim rw As Integer

With Worksheets("Filters")

For rw = 1 To .Range("a1:a" & Cells(65536, 1).End(xlUp).Row)

If Cells(rw, 3).Value = 0 And Cells(rw, 4).Value = 0 Then

Cells(rw, 4).EntireRow.Delete

rw = rw - 1

End If

Next

End With

End Sub


When this code runs I get an "Error 13, Type Mismatch".

Any thoughts, hints, or suggestions??

Is there a better way to do this?

By the by, the workbook hides when the forms load so the user never sees it.

Thanks in advance

Dave

Here is the original post of the above code http://www.mrexcel.com/board/viewtopic.php?topic=10744&forum=2
 
Hi Dave,
Just an idea-
You must not use macro here deleting rows, it cuold be handled easily by Advanced Filter:

Filter your data on a criteria which contains formula checking if the 2 adujcent cells are not empty (TRUE), and copying the filtered data to another location.

No macro
No delete rows

Just a new approach,

Eli
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
New Poster:

Code works great with the addition of:

worksheets("Filters").select

for some reason it looks like I have to select each sheet that I need to run this code on, No big deal though:)

Thanks for the Help


Jim:

I try to put some value in very cell, ran into too many problems with the dreaded "is it a space or a null" (see, I can learn, no matter what the wife says :)


Andrew:

There's only 4 rows of data and 2 header rows on the sheet, but Thanks for the info! That could come in handy:)

Eli:

Thanks for the filter suggestion, but I would rather hide and secure everything that I can and I'm not sure I can secure the filtering (some folks around here can break an anvil with a rubber hammer).

Again, Thanks for the help and suggestions. With a bit of luck, and ALOT of help from the people on this board, I should have this project finished in...oh say, 30 or 40 more years:)

Thanks again

Dave
 
Upvote 0
New Poster:

Code works great with the addition of:

worksheets("Filters").select

for some reason it looks like I have to select each sheet that I need to run this code on, No big deal though:)

Thanks for the Help


Jim:

I try to put some value in very cell, ran into too many problems with the dreaded "is it a space or a null" (see, I can learn, no matter what the wife says :)


Andrew:

There's only 4 rows of data and 2 header rows on the sheet, but Thanks for the info! That could come in handy:)

Eli:

Thanks for the filter suggestion, but I would rather hide and secure everything that I can and I'm not sure I can secure the filtering (some folks around here can break an anvil with a rubber hammer).

Again, Thanks for the help and suggestions. With a bit of luck, and ALOT of help from the people on this board, I should have this project finished in...oh say, 30 or 40 more years:)

Thanks again

Dave
 
Upvote 0

Forum statistics

Threads
1,216,434
Messages
6,130,611
Members
449,584
Latest member
c_clark

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top