Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to delete row if column is blank or certain text

Hi all, sorry for asking this question, but I am new and still learning VBA,
but would like a little help if possible. What I would like to have happen,
is if a cell in column C is blank, or contains a set of numbers like
'1540/06', then it would delete that row. The last two numbers is the day of
the month, so if the last two numbers were not the current day of month, then
it would delete that row. Example below; lets say todays date is the 5th, I
would like it to delete rows 1 & 3, because the date is incorrect in Col C in
row 1, and blank cell in Col C in row 3.

A B C
363 MEM 1450/06
616 BOS 2356/05
225 MEM
455 LAX 1767/05
224 LAX 0540/05

Thanks for any help you could give.

Steve D.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to delete row if column is blank or certain text

Thanks for the quick reply Don. I am still having a problem, it won't delete
all the rows if Column C is blank,(it does some), and for seeing the last two
numbers after the '/' as a date, and deleting the row if those numbers are
not of todays date, it deletes some of them, but not all.

Thanks....Steve D.

"Don Guillett" wrote:

try
Sub deleteifnottoday()
For Each c In Range("c12:c18")
If Len(c) 0 And Right(c, 2) < _
Format(Day(Date), "00") Then c.EntireRow.Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Steve D." <Steve wrote in message
...
Hi all, sorry for asking this question, but I am new and still learning
VBA,
but would like a little help if possible. What I would like to have
happen,
is if a cell in column C is blank, or contains a set of numbers like
'1540/06', then it would delete that row. The last two numbers is the day
of
the month, so if the last two numbers were not the current day of month,
then
it would delete that row. Example below; lets say todays date is the 5th,
I
would like it to delete rows 1 & 3, because the date is incorrect in Col C
in
row 1, and blank cell in Col C in row 3.

A B C
363 MEM 1450/06
616 BOS 2356/05
225 MEM
455 LAX 1767/05
224 LAX 0540/05

Thanks for any help you could give.

Steve D.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default How to delete row if column is blank or certain text

the len(c)0 is meant to KEEP blanks because you said you ONLY wanted to
delete those without todays date. Perhaps you can send a SMALL workbook to
my private email below.

--
Don Guillett
SalesAid Software

"Steve D." wrote in message
...
Thanks for the quick reply Don. I am still having a problem, it won't
delete
all the rows if Column C is blank,(it does some), and for seeing the last
two
numbers after the '/' as a date, and deleting the row if those numbers are
not of todays date, it deletes some of them, but not all.

Thanks....Steve D.

"Don Guillett" wrote:

try
Sub deleteifnottoday()
For Each c In Range("c12:c18")
If Len(c) 0 And Right(c, 2) < _
Format(Day(Date), "00") Then c.EntireRow.Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Steve D." <Steve wrote in message
...
Hi all, sorry for asking this question, but I am new and still learning
VBA,
but would like a little help if possible. What I would like to have
happen,
is if a cell in column C is blank, or contains a set of numbers like
'1540/06', then it would delete that row. The last two numbers is the
day
of
the month, so if the last two numbers were not the current day of
month,
then
it would delete that row. Example below; lets say todays date is the
5th,
I
would like it to delete rows 1 & 3, because the date is incorrect in
Col C
in
row 1, and blank cell in Col C in row 3.

A B C
363 MEM 1450/06
616 BOS 2356/05
225 MEM
455 LAX 1767/05
224 LAX 0540/05

Thanks for any help you could give.

Steve D.






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default How to delete row if column is blank or certain text

After seeing the workbook, this is the solution. Dates need to be trimmed
and you need to go from the bottom up.

Sub deleteifnottoday()
x = Cells(Rows.Count, "a").End(xlUp).Row
For i = x To 8 Step -1
If Right(Trim(Cells(i, "c")), 2) < Format(Day(Date), "00") _
Then Cells(i, "c").EntireRow.Delete
Next i
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
the len(c)0 is meant to KEEP blanks because you said you ONLY wanted to
delete those without todays date. Perhaps you can send a SMALL workbook to
my private email below.

--
Don Guillett
SalesAid Software

"Steve D." wrote in message
...
Thanks for the quick reply Don. I am still having a problem, it won't
delete
all the rows if Column C is blank,(it does some), and for seeing the last
two
numbers after the '/' as a date, and deleting the row if those numbers
are
not of todays date, it deletes some of them, but not all.

Thanks....Steve D.

"Don Guillett" wrote:

try
Sub deleteifnottoday()
For Each c In Range("c12:c18")
If Len(c) 0 And Right(c, 2) < _
Format(Day(Date), "00") Then c.EntireRow.Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Steve D." <Steve wrote in message
...
Hi all, sorry for asking this question, but I am new and still
learning
VBA,
but would like a little help if possible. What I would like to have
happen,
is if a cell in column C is blank, or contains a set of numbers like
'1540/06', then it would delete that row. The last two numbers is the
day
of
the month, so if the last two numbers were not the current day of
month,
then
it would delete that row. Example below; lets say todays date is the
5th,
I
would like it to delete rows 1 & 3, because the date is incorrect in
Col C
in
row 1, and blank cell in Col C in row 3.

A B C
363 MEM 1450/06
616 BOS 2356/05
225 MEM
455 LAX 1767/05
224 LAX 0540/05

Thanks for any help you could give.

Steve D.









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to delete row if column is blank or certain text

Don,
Thanks for all the help, it works great.

Thanks,
Steve

"Don Guillett" wrote:

After seeing the workbook, this is the solution. Dates need to be trimmed
and you need to go from the bottom up.

Sub deleteifnottoday()
x = Cells(Rows.Count, "a").End(xlUp).Row
For i = x To 8 Step -1
If Right(Trim(Cells(i, "c")), 2) < Format(Day(Date), "00") _
Then Cells(i, "c").EntireRow.Delete
Next i
End Sub

--
Don Guillett
SalesAid Software

"Don Guillett" wrote in message
...
the len(c)0 is meant to KEEP blanks because you said you ONLY wanted to
delete those without todays date. Perhaps you can send a SMALL workbook to
my private email below.

--
Don Guillett
SalesAid Software

"Steve D." wrote in message
...
Thanks for the quick reply Don. I am still having a problem, it won't
delete
all the rows if Column C is blank,(it does some), and for seeing the last
two
numbers after the '/' as a date, and deleting the row if those numbers
are
not of todays date, it deletes some of them, but not all.

Thanks....Steve D.

"Don Guillett" wrote:

try
Sub deleteifnottoday()
For Each c In Range("c12:c18")
If Len(c) 0 And Right(c, 2) < _
Format(Day(Date), "00") Then c.EntireRow.Delete
Next
End Sub

--
Don Guillett
SalesAid Software

"Steve D." <Steve wrote in message
...
Hi all, sorry for asking this question, but I am new and still
learning
VBA,
but would like a little help if possible. What I would like to have
happen,
is if a cell in column C is blank, or contains a set of numbers like
'1540/06', then it would delete that row. The last two numbers is the
day
of
the month, so if the last two numbers were not the current day of
month,
then
it would delete that row. Example below; lets say todays date is the
5th,
I
would like it to delete rows 1 & 3, because the date is incorrect in
Col C
in
row 1, and blank cell in Col C in row 3.

A B C
363 MEM 1450/06
616 BOS 2356/05
225 MEM
455 LAX 1767/05
224 LAX 0540/05

Thanks for any help you could give.

Steve D.








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
macro to delete rows if cell blank in column puiuluipui Excel Discussion (Misc queries) 4 October 15th 09 05:22 PM
Delete row if blank in a column Outlook, eh? Excel Worksheet Functions 5 December 8th 07 02:46 PM
I cannot delete a blank column from an Excel spreadsheet. Chris L 99 Excel Discussion (Misc queries) 3 October 12th 06 01:08 PM
If field in column is blank, delete if.... CPower[_30_] Excel Programming 1 August 6th 04 03:23 AM
Delete Entire Row If Column C is Blank John Excel Programming 5 July 19th 04 10:23 PM


All times are GMT +1. The time now is 04:09 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"