#1   Report Post  
Posted to microsoft.public.excel.misc
Rokuro kubi
 
Posts: n/a
Default If Else statement

I'm fairly new to this and there are some frustrating gaps in what I
know of the basics. In the last section of code below, in the event
that DelRng6 = Nothing, how do I get the macro to simply move on to the
next code without doing anything else?

Dim DelRng6 As Range

Set myRng = Range(Cells(1, ActiveCell.Column), _
Cells(Rows.Count, ActiveCell.Column).End(xlUp))

For Each myCell In myRng.Cells
If myCell.Value = "Value" Then
If DelRng6 Is Nothing Then
Set DelRng6 = myCell
Else
Set DelRng6 = Union(myCell, DelRng6)
End If
End If
Next myCell

If DelRng6 Is Nothing Then
??????
Else
DelRng6.EntireRow.Delete

Range("B2").Delete

  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave Peterson
 
Posts: n/a
Default If Else statement

You could use:

If DelRng6 Is Nothing Then
Else
DelRng6.EntireRow.Delete
End if

or

If not (DelRng6 Is Nothing) Then
DelRng6.EntireRow.Delete
end if

I like:

If DelRng6 Is Nothing Then
'do nothing
Else
DelRng6.EntireRow.Delete
end if

I think it makes it easy to see what's happening.

Rokuro kubi wrote:

I'm fairly new to this and there are some frustrating gaps in what I
know of the basics. In the last section of code below, in the event
that DelRng6 = Nothing, how do I get the macro to simply move on to the
next code without doing anything else?

Dim DelRng6 As Range

Set myRng = Range(Cells(1, ActiveCell.Column), _
Cells(Rows.Count, ActiveCell.Column).End(xlUp))

For Each myCell In myRng.Cells
If myCell.Value = "Value" Then
If DelRng6 Is Nothing Then
Set DelRng6 = myCell
Else
Set DelRng6 = Union(myCell, DelRng6)
End If
End If
Next myCell

If DelRng6 Is Nothing Then
??????
Else
DelRng6.EntireRow.Delete

Range("B2").Delete


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
Rokuro kubi
 
Posts: n/a
Default If Else statement

Cheers Dave

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
reconcile two months statement? achilles Excel Discussion (Misc queries) 0 March 17th 06 03:47 AM
SET statement tutorial Daminc Excel Discussion (Misc queries) 13 January 17th 06 04:47 PM
If statement Matt Montagliano Excel Discussion (Misc queries) 1 September 8th 05 08:47 PM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
IF Statement Brent New Users to Excel 3 April 29th 05 04:24 PM


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

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"