Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default How to Write a sub to execute the following

If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default How to Write a sub to execute the following

Public Sub DoSomething()
If ActiveSheet.Range("A2").Text = "" and ActiveSheet.Range("A2").Text = "New" Then Exit Sub
If ActiveSheet.Range("A2").Text = "" and not (ActiveSheet.Range("A2").Text = "New") Then
'Do stuff
End if
End Sub

NOTE: however, 1 1st IF is not necessary because if the 2nd IF is true, the 1st IF must be false

'This is all that is needed to satisfy your critira (unless you intend to do other combination checks, then go with the
1st solution)
Public Sub DoSomething()
If ActiveSheet.Range("A2").Text = "" and not (ActiveSheet.Range("A2").Text = "New") Then
'Do stuff
End if
End Sub

PS, watch for line breaks in the code samples above;
If ...blah...blah.... Then should be on 1 line.


"Ronald Cayne" wrote in message ...
If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default How to Write a sub to execute the following

IF Range("A2")= "" then
IF Range("C2")="New" Then
Exit Sub
Else
'do something else
End If
End if


"Ronald Cayne" wrote:

If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default How to Write a sub to execute the following

Ronald Cayne wrote:
If a2="" and c2="New"
Exit Subroutine
If a2="" and c2 not equal to the word New then continue executing the
subroutine


And if a2<""?

Alan Beban
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
Button to execute Add-in Aerojade Excel Discussion (Misc queries) 3 October 3rd 08 09:46 PM
Five plus mintues to execute CB Excel Discussion (Misc queries) 5 August 25th 08 09:48 PM
concatenate and then execute? miwarren Excel Worksheet Functions 6 October 17th 05 09:26 PM
is it possible to execute write to the fields in another .xsl form a macro in another .xsl? e.g. some way to load another .xsl into an .xsl macro and write to its data? Daniel Excel Worksheet Functions 1 June 23rd 05 11:38 PM
Could not execute Gary Excel Worksheet Functions 1 December 20th 04 06:20 PM


All times are GMT +1. The time now is 07:24 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"