Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Ty Ty is offline
external usenet poster
 
Posts: 72
Default Macro to Delete a Row

I posted a problem under "Excel Delete VB Macro" in the microsoft.*
public.*excel.*worksheet.*functions. And another one called VLOOKUP
in the last 5 days. All of the problems were resolved. i have 3 more
questions.

What if I just wanted to delete rows that have the cell blank?

my answer: ActiveCell.Interior.Color = RGB(255, 0, 0) need to
change
the RGB to the empty cell numbers(0, 0, 0)

What if I just wanted to delete rows that have #N/A in the cell
blank?

my answer: ActiveCell = #N/A

What if I had another column such as column J as a condition to the
above to not delete with my initials like TB?

my answer: If ActiveCell.Interior.Color = RGB(255, 0, 0) + column J
is
blank. Don't really have answer but I'm trying to figure this out on
my own.


Thanks for your help....
Ty
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ty Ty is offline
external usenet poster
 
Posts: 72
Default Macro to Delete a Row

On Aug 6, 9:10*am, Ty wrote:
I posted a problem under "Excel Delete VB Macro" in the microsoft.*
public.*excel.*worksheet.*functions. *And another one called VLOOKUP
in the last 5 days. *All of the problems were resolved. *i have 3 more
questions.

What if *I just wanted to delete rows that have the cell blank?

my answer: *ActiveCell.Interior.Color = RGB(255, 0, 0) *need to
change
the RGB to the empty cell numbers(0, 0, 0)

What if *I just wanted to delete rows that have #N/A in the cell
blank?

my answer: *ActiveCell = #N/A

What if I had another column such as column J as a condition to the
above to not delete with my initials like TB?

my answer: If ActiveCell.Interior.Color = RGB(255, 0, 0) + column J
is
blank. *Don't really have answer but I'm trying to figure this out on
my own.

Thanks for your help....
Ty


I attempted to do one of my answers up top and if failed with an
error. Changed it to ActiveCell.Value = "#N/A". Now, I have an error
and the Do While line is yellow. The "active cell error 2042"
displays when I put my cursor over the [Do While ActiveCell < ""]
line. Here is the complete Macro:

Sub MacroTy()
'
' MacroTy Macro
' Macro recorded 7/30/2009 by Ty
'

'
ScreenUpdating = False
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1

Do While ActiveCell < ""
If ActiveCell.Value = "#N/A" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
ScreenUpdating = True
End Sub

Help?

Thanks...
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Macro to Delete a Row

Assuming there will not be thousands of rows whose formulas equate to the
#NA error, here is how I would write that function...

Sub RemoveRowsWithNA()
Dim C As Range, U As Range
For Each C In Columns("K").SpecialCells(xlCellTypeFormulas, xlErrors)
If C.Value = CVErr(xlErrNA) Then
If U Is Nothing Then
Set U = C
Else
Set U = Union(U, C)
End If
End If
Next
If Not U Is Nothing Then U.EntireRow.Delete
End Sub

Note that I have set the column in the For Each statement rather than use
the ActiveCell... just change my example Column "K" designation to the
column you actually want to search for the #NA errors in.

--
Rick (MVP - Excel)


"Ty" wrote in message
...
On Aug 6, 9:10 am, Ty wrote:
I posted a problem under "Excel Delete VB Macro" in the microsoft.*
public.*excel.*worksheet.*functions. And another one called VLOOKUP
in the last 5 days. All of the problems were resolved. i have 3 more
questions.

What if I just wanted to delete rows that have the cell blank?

my answer: ActiveCell.Interior.Color = RGB(255, 0, 0) need to
change
the RGB to the empty cell numbers(0, 0, 0)

What if I just wanted to delete rows that have #N/A in the cell
blank?

my answer: ActiveCell = #N/A

What if I had another column such as column J as a condition to the
above to not delete with my initials like TB?

my answer: If ActiveCell.Interior.Color = RGB(255, 0, 0) + column J
is
blank. Don't really have answer but I'm trying to figure this out on
my own.

Thanks for your help....
Ty


I attempted to do one of my answers up top and if failed with an
error. Changed it to ActiveCell.Value = "#N/A". Now, I have an error
and the Do While line is yellow. The "active cell error 2042"
displays when I put my cursor over the [Do While ActiveCell < ""]
line. Here is the complete Macro:

Sub MacroTy()
'
' MacroTy Macro
' Macro recorded 7/30/2009 by Ty
'

'
ScreenUpdating = False
FirstItem = ActiveCell.Value
SecondItem = ActiveCell.Offset(1, 0).Value
Offsetcount = 1

Do While ActiveCell < ""
If ActiveCell.Value = "#N/A" Then
ActiveCell.EntireRow.Delete
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
ScreenUpdating = True
End Sub

Help?

Thanks...

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Delete a Row

Without knowing anything about the code you're using...

#1. if isempty(activecell.value) then
#2. if lcase(activecell.text) = lcase("#N/A") then
#3. if ActiveCell.Interior.Color = RGB(255, 0, 0) _
and isempty(cells(activecell.row,"J").value) then

I hope that your delete code is working from the bottom up--it really makes
deleting much easier.

Personally, I wouldn't loop through the range using the activecell. I'd just
start a bottom row and work my way up.

Dim FirstRow as long
dim LastRow as long
dim iRow as long

with activesheet
firstrow = 2 'headers in row 1????
'last row determined by the data in column A (in my example)
lastrow = .cells(.rows.count,"A").end(xlup).row

for irow = lastrow to firstrow step -1
'what column should be tested? I used X.
if isempty(.cells(irow,"X").value) then
.rows(irow).delete
end if
next irow
end with

======
All untested, uncompiled. Watch for typos.




Ty wrote:

I posted a problem under "Excel Delete VB Macro" in the microsoft.*
public.*excel.*worksheet.*functions. And another one called VLOOKUP
in the last 5 days. All of the problems were resolved. i have 3 more
questions.

What if I just wanted to delete rows that have the cell blank?

my answer: ActiveCell.Interior.Color = RGB(255, 0, 0) need to
change
the RGB to the empty cell numbers(0, 0, 0)

What if I just wanted to delete rows that have #N/A in the cell
blank?

my answer: ActiveCell = #N/A

What if I had another column such as column J as a condition to the
above to not delete with my initials like TB?

my answer: If ActiveCell.Interior.Color = RGB(255, 0, 0) + column J
is
blank. Don't really have answer but I'm trying to figure this out on
my own.

Thanks for your help....
Ty


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Delete a Row

Check your other post.

Ty wrote:

I posted a problem under "Excel Delete VB Macro" in the microsoft.*
public.*excel.*worksheet.*functions. And another one called VLOOKUP
in the last 5 days. All of the problems were resolved. i have 3 more
questions.

What if I just wanted to delete rows that have the cell blank?

my answer: ActiveCell.Interior.Color = RGB(255, 0, 0) need to
change
the RGB to the empty cell numbers(0, 0, 0)

What if I just wanted to delete rows that have #N/A in the cell
blank?

my answer: ActiveCell = #N/A

What if I had another column such as column J as a condition to the
above to not delete with my initials like TB?

my answer: If ActiveCell.Interior.Color = RGB(255, 0, 0) + column J
is
blank. Don't really have answer but I'm trying to figure this out on
my own.

Thanks for your help....
Ty


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Macro to Delete a Row

Oops. Ignore this message.

Dave Peterson wrote:

Check your other post.

Ty wrote:

I posted a problem under "Excel Delete VB Macro" in the microsoft.*
public.*excel.*worksheet.*functions. And another one called VLOOKUP
in the last 5 days. All of the problems were resolved. i have 3 more
questions.

What if I just wanted to delete rows that have the cell blank?

my answer: ActiveCell.Interior.Color = RGB(255, 0, 0) need to
change
the RGB to the empty cell numbers(0, 0, 0)

What if I just wanted to delete rows that have #N/A in the cell
blank?

my answer: ActiveCell = #N/A

What if I had another column such as column J as a condition to the
above to not delete with my initials like TB?

my answer: If ActiveCell.Interior.Color = RGB(255, 0, 0) + column J
is
blank. Don't really have answer but I'm trying to figure this out on
my own.

Thanks for your help....
Ty


--

Dave Peterson


--

Dave Peterson
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 sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:16 PM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM


All times are GMT +1. The time now is 03:43 AM.

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

About Us

"It's about Microsoft Excel"