Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Skip condition if cell is blank | Excel Programming | |||
Combine and display values in range in 1 cell but skip blank cells | Excel Worksheet Functions | |||
skip to next part of program if a cell blank | Excel Programming | |||
How do I skip a blank cell within macro? | Excel Programming | |||
skip cell if blank go on to use another cell in calculation | Excel Programming |