Note that there are some explanatory texts on larger screens.

plurals
  1. POExcel Macro Repetitive IF and Else
    primarykey
    data
    text
    <p>I am currently working on an Excel VBA Macro script where in it will do a simple TRUE or False test to the active cell. My problem is, i cannot make this working until the end of the list. It only run once and ends the program. I need this VB script to perform the IF &amp; ELSE test up to the bottom of the list.</p> <p>Description of the problem:</p> <p>Let's say i have a list of dates in A1 to A9999 and beside it (F1:F9999) there's also a list that has a text on it. the F1:F9999 list contains two values only. (a)SAME DATE and (b) NOT THE SAME.</p> <ol> <li><p>Perform a True or False test in the List F1:F9999. </p></li> <li><p>If the active cell value is equal to the text "SAME DATE" (TRUE), it will ignore and move to the next item in the list then perform again number 1.</p></li> <li>If the active cell value is equal to the text "SAME DATE" (FALSE), it will insert a row above it and then move to the next item in the list then perform again number 1</li> <li>The TRUE or FALSE test will run until the end of the list.</li> <li>The TRUE or FALSE test will stop running if it reached the bottom of the list.</li> <li>by the way, the number of items in the list is not consistent. I just put there F1:F9999 for example purposes.</li> </ol> <p>here's my code!</p> <pre><code>Sub IFandElseTest() If ActiveCell.Value = "Same Date" Then Range(Selection, Cells(ActiveCell.Row, 1)).Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove ActiveCell.Offset(1, 0).Select Else: ActiveCell.Offset(1, 0).Select Range(Selection, Cells(ActiveCell.Row, 1)).Select Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove End If End Sub </code></pre> <p><img src="https://i.stack.imgur.com/T19jd.jpg" alt="enter image description here"></p> <p>Appreaciate if you could help me on this. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload