Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Skip condition if cell is blank

I have 4 conditions

1) If Sheets("Details").Range("H" & lngRow) Date - 90 And _
2) Sheets("Details").Range("F" & lngRow) = Sheets("Search").Range("C2") And _
3) Sheets("Details").Range("J" & lngRow) = Sheets("Search").Range("C4") And _
4) Sheets("Details").Range("I" & lngRow) = Sheets("Search").Range("E4") Then

if Sheets("Search").Range("E2") is blank then condition 1 should be skipped
if Sheets("Search").Range("C2") is blank then condition 2 should be skipped
if Sheets("Search").Range("C4") is blank then condition 3 should be skipped
if Sheets("Search").Range("E4") is blank then condition 4 should be skipped

Please help me with this..

--------------------------------------

Sub GetAll()
Dim lngRow As Long
Dim lngLastRow As Long
Dim lngNewRow As Long
Dim varTemp As Variant

Sheets("Search").Select
Range("A9:L65536").Select
Selection.ClearContents
Application.Goto Reference:="R9C1"

Application.ScreenUpdating = False
lngLastRow = Sheets("Details").Cells(Rows.Count, "B").End(xlUp).Row
lngNewRow = Sheets("Search").Cells(Rows.Count, "A").End(xlUp).Row + 1
For lngRow = 1 To lngLastRow

If Sheets("Details").Range("H" & lngRow) Date - 90 And _
Sheets("Details").Range("F" & lngRow) = Sheets("Search").Range("C2") And _
Sheets("Details").Range("J" & lngRow) = Sheets("Search").Range("C4") And _
Sheets("Details").Range("I" & lngRow) = Sheets("Search").Range("E4") Then

varTemp = Sheets("Details").Range(lngRow & ":" & lngRow)
Sheets(4).Range(lngNewRow & ":" & lngNewRow) = varTemp
lngNewRow = lngNewRow + 1
End If
Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 563
Default Skip condition if cell is blank

Not sure I totally understand question but:
Untested but this is what I would try to 'skip' the first test
If (Sheets("Details").Range("H" & lngRow) Date - 90 or
Sheets("Search").Range("E2") ="") And _
Sheets("Details").Range("F" & lngRow) = Sheets("Search").Range("C2") And _
Sheets("Details").Range("J" & lngRow) = Sheets("Search").Range("C4") And _
Sheets("Details").Range("I" & lngRow) = Sheets("Search").Range("E4")

If this works for you then extend the method to the other tests.
best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme

"Kash" wrote in message
...
I have 4 conditions

1) If Sheets("Details").Range("H" & lngRow) Date - 90 And _
2) Sheets("Details").Range("F" & lngRow) = Sheets("Search").Range("C2")
And _
3) Sheets("Details").Range("J" & lngRow) = Sheets("Search").Range("C4")
And _
4) Sheets("Details").Range("I" & lngRow) = Sheets("Search").Range("E4")
Then

if Sheets("Search").Range("E2") is blank then condition 1 should be
skipped
if Sheets("Search").Range("C2") is blank then condition 2 should be
skipped
if Sheets("Search").Range("C4") is blank then condition 3 should be
skipped
if Sheets("Search").Range("E4") is blank then condition 4 should be
skipped

Please help me with this..

--------------------------------------

Sub GetAll()
Dim lngRow As Long
Dim lngLastRow As Long
Dim lngNewRow As Long
Dim varTemp As Variant

Sheets("Search").Select
Range("A9:L65536").Select
Selection.ClearContents
Application.Goto Reference:="R9C1"

Application.ScreenUpdating = False
lngLastRow = Sheets("Details").Cells(Rows.Count, "B").End(xlUp).Row
lngNewRow = Sheets("Search").Cells(Rows.Count, "A").End(xlUp).Row + 1
For lngRow = 1 To lngLastRow

If Sheets("Details").Range("H" & lngRow) Date - 90 And _
Sheets("Details").Range("F" & lngRow) = Sheets("Search").Range("C2") And _
Sheets("Details").Range("J" & lngRow) = Sheets("Search").Range("C4") And _
Sheets("Details").Range("I" & lngRow) = Sheets("Search").Range("E4") Then

varTemp = Sheets("Details").Range(lngRow & ":" & lngRow)
Sheets(4).Range(lngNewRow & ":" & lngNewRow) = varTemp
lngNewRow = lngNewRow + 1
End If
Next


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Skip condition if cell is blank

I actually need to skip only that particular statement if a particular cell
is blank.. other statements shouls execute..

if Sheets("Search").Range("E2") is blank then condition 1 should be skipped
if Sheets("Search").Range("C2") is blank then condition 2 should be skipped
if Sheets("Search").Range("C4") is blank then condition 3 should be skipped
if Sheets("Search").Range("E4") is blank then condition 4 should be skipped

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
Skip condition if cell is blank Kash Excel Programming 14 May 25th 10 02:33 AM
Combine and display values in range in 1 cell but skip blank cells Swiss Excel Worksheet Functions 3 September 4th 09 10:00 PM
skip to next part of program if a cell blank SteveC Excel Programming 4 February 20th 09 07:51 PM
How do I skip a blank cell within macro? DJ Dusty[_6_] Excel Programming 3 March 20th 06 11:17 PM
skip cell if blank go on to use another cell in calculation sosborne Excel Programming 0 March 8th 06 09:33 PM


All times are GMT +1. The time now is 06:37 AM.

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"