PC Review


Reply
Thread Tools Rate Thread

Delete all rows where there is no entry in Column 'C'

 
 
andreashermle
Guest
Posts: n/a
 
      31st May 2010
Dear Experts:

I got a multi-column, mulit-row table with numerous data records. Some
records do not have any entry in Column 'C'.

I now would like to be able via a macro to delete all records that do
not have any entry in Column C.

How is this achieved?

Thank you very much in advance for your great help.

Regards, Andreas
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      31st May 2010
Public Sub DeleteRowOnCell()

Set coltocheck = Columns(3)

'if you want user-selectable column use inputbox

'Set coltocheck = Application.InputBox(prompt:= _
' "Select A Column", Type:=8)

coltocheck.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

End Sub


Gord Dibben MS Excel MVP

On Mon, 31 May 2010 08:52:37 -0700 (PDT), andreashermle
<(E-Mail Removed)> wrote:

>Dear Experts:
>
>I got a multi-column, mulit-row table with numerous data records. Some
>records do not have any entry in Column 'C'.
>
>I now would like to be able via a macro to delete all records that do
>not have any entry in Column C.
>
>How is this achieved?
>
>Thank you very much in advance for your great help.
>
>Regards, Andreas


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st May 2010
One way -
Add an autofilter to the top of column C
In the drop down select Blanks
Delete the filtered rows, if any
Remove the filter

Note though there must be at least one entry in each row of the filter
range, below which the filter will not work.

You could do that with a macro but it's barely worth it, and manually you
will keep your Undo stack.

Regards,
Peter T


"andreashermle" <(E-Mail Removed)> wrote in message
news:268cb927-cea2-446f-9e00-(E-Mail Removed)...
> Dear Experts:
>
> I got a multi-column, mulit-row table with numerous data records. Some
> records do not have any entry in Column 'C'.
>
> I now would like to be able via a macro to delete all records that do
> not have any entry in Column C.
>
> How is this achieved?
>
> Thank you very much in advance for your great help.
>
> Regards, Andreas



 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      1st Jun 2010
On May 31, 6:27*pm, Gord Dibben <gorddibbATshawDOTca> wrote:
> Public Sub DeleteRowOnCell()
>
> * * Set coltocheck = Columns(3)
>
> * * 'if you want user-selectable column use inputbox
>
> * *'Set coltocheck = Application.InputBox(prompt:= _
> * * * * * ' *"Select A Column", Type:=8)
>
> * * coltocheck.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
>
> End Sub
>
> Gord Dibben *MS Excel MVP
>
> On Mon, 31 May 2010 08:52:37 -0700 (PDT), andreashermle
>
>
>
> <andreas.her...@gmx.de> wrote:
> >Dear Experts:

>
> >I got a multi-column, mulit-row table with numerous data records. Some
> >records do not have any entry in Column 'C'.

>
> >I now would like to be able via a macro to delete all records that do
> >not have any entry in Column C.

>
> >How is this achieved?

>
> >Thank you very much in advance for your great help.

>
> >Regards, Andreas- Hide quoted text -

>
> - Show quoted text -


Hi Gord,

thank you very much for your swift help. I am afraid to tell you that
I am getting a compile error telling me that the variable 'coltocheck'
is not defined.

Regards, Andreas
 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      1st Jun 2010
On May 31, 6:27*pm, joel <joel.4bu...@thecodecage.com> wrote:
> try this
>
> Sub Macro1()
> '
> With Sheets("sheet1")
> LastRow = .Range("C" & Rows.Count).End(xlUp).Row
> 'use autofile to get blank items
> .Columns("C:C").AutoFilter
> .Columns("C:C").AutoFilter Field:=1, Criteria1:="="
>
> 'use special cells method to get visible rows, ones with blanks
> Set VisibleRows = .Rows("1:" & LastRow) _
> .SpecialCells(xlCellTypeVisible)
> VisibleRows.Delete
> 'remove autofilter
> .Cells.AutoFilter
> End With
> End Sub
>
> --
> joel
> ------------------------------------------------------------------------
> joel's Profile:http://www.thecodecage.com/forumz/member.php?u=229
> View this thread:http://www.thecodecage.com/forumz/sh...d.php?t=206269
>
> http://www.thecodecage.com/forumz


Hi Joel,

it is working as desired. Thank you very much for your great help. I
had to delete the 'Option Explicit' statement in order not to get
constant error messages, that a variable has not been defined. What do
I have to do if I leave the 'Option Explicit' statement on its place.

Regards, Andreas
 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      1st Jun 2010
On May 31, 6:28*pm, "Peter T" <peter_t@discussions> wrote:
> One way -
> Add an autofilter to the top of column C
> In the drop down select Blanks
> Delete the filtered rows, if any
> Remove the filter
>
> Note though there must be at least one entry in each row of the filter
> range, below which the filter will not work.
>
> You could do that with a macro but it's barely worth it, and manually you
> will keep your Undo stack.
>
> Regards,
> Peter T
>
> "andreashermle" <andreas.her...@gmx.de> wrote in message
>
> news:268cb927-cea2-446f-9e00-(E-Mail Removed)...
>
>
>
> > Dear Experts:

>
> > I got a multi-column, mulit-row table with numerous data records. Some
> > records do not have any entry in Column 'C'.

>
> > I now would like to be able via a macro to delete all records that do
> > not have any entry in Column C.

>
> > How is this achieved?

>
> > Thank you very much in advance for your great help.

>
> > Regards, Andreas- Hide quoted text -

>
> - Show quoted text -


Hey Peter,

ok, great thank you. One often forgets that there are very good built-
in functionalties. Now I got both approaches. That's very good.

Thank you very much for your professional help. Regards, Andreas
 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      1st Jun 2010
On May 31, 6:27*pm, Gord Dibben <gorddibbATshawDOTca> wrote:
> Public Sub DeleteRowOnCell()
>
> * * Set coltocheck = Columns(3)
>
> * * 'if you want user-selectable column use inputbox
>
> * *'Set coltocheck = Application.InputBox(prompt:= _
> * * * * * ' *"Select A Column", Type:=8)
>
> * * coltocheck.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
>
> End Sub
>
> Gord Dibben *MS Excel MVP
>
> On Mon, 31 May 2010 08:52:37 -0700 (PDT), andreashermle
>
>
>
> <andreas.her...@gmx.de> wrote:
> >Dear Experts:

>
> >I got a multi-column, mulit-row table with numerous data records. Some
> >records do not have any entry in Column 'C'.

>
> >I now would like to be able via a macro to delete all records that do
> >not have any entry in Column C.

>
> >How is this achieved?

>
> >Thank you very much in advance for your great help.

>
> >Regards, Andreas- Hide quoted text -

>
> - Show quoted text -


Hi again,

as with joel's code, if I delete the 'Option Explicit' Statement, it
is running just fine. Thank you very much for your professional help.
Regards, Andreas
 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      1st Jun 2010
You must have Option Explicit at top of module.

Add a line after Public Sub DeleteRowOnCell()

Dim coltocheck as Range

Aplogies for that.


Gord

On Mon, 31 May 2010 20:54:02 -0700 (PDT), andreashermle
<(E-Mail Removed)> wrote:

>On May 31, 6:27*pm, Gord Dibben <gorddibbATshawDOTca> wrote:
>> Public Sub DeleteRowOnCell()
>>
>> * * Set coltocheck = Columns(3)
>>
>> * * 'if you want user-selectable column use inputbox
>>
>> * *'Set coltocheck = Application.InputBox(prompt:= _
>> * * * * * ' *"Select A Column", Type:=8)
>>
>> * * coltocheck.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
>>
>> End Sub
>>
>> Gord Dibben *MS Excel MVP
>>
>> On Mon, 31 May 2010 08:52:37 -0700 (PDT), andreashermle
>>
>>
>>
>> <andreas.her...@gmx.de> wrote:
>> >Dear Experts:

>>
>> >I got a multi-column, mulit-row table with numerous data records. Some
>> >records do not have any entry in Column 'C'.

>>
>> >I now would like to be able via a macro to delete all records that do
>> >not have any entry in Column C.

>>
>> >How is this achieved?

>>
>> >Thank you very much in advance for your great help.

>>
>> >Regards, Andreas- Hide quoted text -

>>
>> - Show quoted text -

>
>Hi Gord,
>
>thank you very much for your swift help. I am afraid to tell you that
>I am getting a compile error telling me that the variable 'coltocheck'
>is not defined.
>
>Regards, Andreas


 
Reply With Quote
 
andreashermle
Guest
Posts: n/a
 
      2nd Jun 2010
On 1 Jun., 16:41, Gord Dibben <gorddibbATshawDOTca> wrote:
> You must have Option Explicit at top of module.
>
> Add a line after *Public Sub DeleteRowOnCell()
>
> Dim coltocheck as Range
>
> Aplogies for that.
>
> Gord
>
> On Mon, 31 May 2010 20:54:02 -0700 (PDT), andreashermle
>
>
>
> <andreas.her...@gmx.de> wrote:
> >On May 31, 6:27*pm, Gord Dibben <gorddibbATshawDOTca> wrote:
> >> Public Sub DeleteRowOnCell()

>
> >> * * Set coltocheck = Columns(3)

>
> >> * * 'if you want user-selectable column use inputbox

>
> >> * *'Set coltocheck = Application.InputBox(prompt:= _
> >> * * * * * ' *"Select A Column", Type:=8)

>
> >> * * coltocheck.SpecialCells(xlCellTypeBlanks).EntireRow.Delete

>
> >> End Sub

>
> >> Gord Dibben *MS Excel MVP

>
> >> On Mon, 31 May 2010 08:52:37 -0700 (PDT), andreashermle

>
> >> <andreas.her...@gmx.de> wrote:
> >> >Dear Experts:

>
> >> >I got a multi-column, mulit-row table with numerous data records. Some
> >> >records do not have any entry in Column 'C'.

>
> >> >I now would like to be able via a macro to delete all records that do
> >> >not have any entry in Column C.

>
> >> >How is this achieved?

>
> >> >Thank you very much in advance for your great help.

>
> >> >Regards, Andreas- Hide quoted text -

>
> >> - Show quoted text -

>
> >Hi Gord,

>
> >thank you very much for your swift help. I am afraid to tell you that
> >I am getting a compile error telling me that the variable 'coltocheck'
> >is not defined.

>
> >Regards, Andreas- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -


ok, thank you very much for your terrific support
 
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
Copy rows where entry in column A access user Microsoft Excel Programming 11 17th Mar 2008 01:13 PM
Delete Rows if any cell in Column H is blank but do not Delete Fir =?Utf-8?B?bWFuZmFyZWVk?= Microsoft Excel Programming 4 28th Sep 2007 05:20 PM
Excel: How copy all rows that have a given column entry? =?Utf-8?B?TW90b3duIE1pY2s=?= Microsoft Excel Misc 20 12th Jun 2007 06:56 PM
Delete Rows containing pop-up entry =?Utf-8?B?Q0xS?= Microsoft Excel Programming 16 4th Jan 2005 06:56 PM
Insert rows depending on entry in certain column Gareth Microsoft Excel Programming 1 12th Dec 2003 03:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:55 PM.