Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I backed up, slowed down and went to some basic programming principles, as slow as they feel at times.</p> <ol> <li>Flowchart</li> <li>Pseudocode</li> <li>prototype</li> <li>test</li> <li>repeat 3 and 4 as needed.</li> </ol> <p>I found that the following code did EXACTLY what I needed. I share it for any who follow.</p> <pre><code>Sub countFoo() Dim startCell As Range Dim preCell As Range Dim counter As Integer Dim startPoint As Range, endPoint As Range Dim fileName As String, delimitingCharacter As String, SQLpre As String, SQLpost As String Dim SQL As String Dim outfile As Integer fileName = "update_foo.sql" SQLpre = "UPDATE foo SET foodata = " SQLpost = " WHERE details = '" outfile = FreeFile() Open fileName For Output As outfile counter = 1 Set startPoint = Cells(2, 4) startPoint.Activate Debug.Print "Start Point:" &amp; startPoint.Address Debug.Print startPoint.Value Set startCell = ActiveCell Set preCell = startCell.Offset(-1, 0) Do While startCell.Value &lt;&gt; "END" If (startCell.Value = preCell.Value) Then counter = counter + 1 Set preCell = startCell Set startCell = startCell.Offset(1, 0) ElseIf ((startCell.Value &lt;&gt; preCell.Value) Or (startCell.Value = "END")) Then startCell.Offset(-1, 3).Value = counter If counter &gt; 1 Then startCell.Offset(-1, 0).Interior.Color = 5296274 startCell.Offset(-1, 1).Interior.Color = 5296274 startCell.Offset(-1, 2).Interior.Color = 5296274 startCell.Offset(-1, 3).Font.Bold = True With startCell.Offset(-1, 3).Interior .Pattern = xlGray8 .PatternColor = 65535 .Color = 5296274 End With End If SQL = SQLpre &amp; counter &amp; SQLpost &amp; startCell.Offset(-1, 0).Value &amp; "';" Print #outfile, SQL counter = 1 Set preCell = startCell Set startCell = startCell.Offset(1, 0) End If Loop Close #outfile End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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