Note that there are some explanatory texts on larger screens.

plurals
  1. POVBA Writes Extra Lines When Impossible To Do So
    primarykey
    data
    text
    <p>I was wokring on the piece of code below, and had it functioning correctly. Somehow a line has changed and meant now it fails to function</p> <p>I have a table of tags and weightings like so:</p> <pre><code>Tag | Weight --------------- Sport | 1 Music | 1 </code></pre> <p>And then another table of users, with tag + weight</p> <pre><code>User | Tag | Weight </code></pre> <hr> <p>The cell(j, "B") contains the username, as does the cell(2,"C") in the other worksheet</p> <p>I am using the following code:</p> <pre><code>Sub swipeleft() LastRowUser = Worksheets(13).Range("B65536").End(xlUp).Row LastRowInput = Worksheets(14).Range("F65536").End(xlUp).Row LastRowUser = LastRowUser + 1 newcount = 1 For j = 2 To LastRowUser For k = 9 To LastRowInput If Worksheets(14).Cells(k, "F") = Worksheets(13).Cells(j, "C") And Worksheets(13).Cells(j, "B") = Worksheets(14).Cells(2, "C") Then Worksheets(13).Cells(j, "D") = Worksheets(13).Cells(j, "D") - Worksheets(14).Cells(k, "G") ElseIf Not Worksheets(13).Cells(j, "B") = Worksheets(14).Cells(2, "C") Then Worksheets(13).Cells(newcount + LastRowUser, "C") = Worksheets(14).Cells(k, "F") Worksheets(13).Cells(newcount + LastRowUser, "D") = Worksheets(14).Cells(k, "G") * (-1) Worksheets(13).Cells(newcount + LastRowUser, "B") = Worksheets(14).Cells(2, "C") newcount = newcount + 1 End If Next k Next j End Sub </code></pre> <p>This adds the rows when data is not present, but for some reason after the first run it keeps adding exponentially more rows, even though the second else condition is not met?</p> <blockquote> <p>UPDATED FROM COMMENTS BELOW</p> </blockquote> <p>Here is the user input page (Worksheet 14): </p> <p><img src="https://i.stack.imgur.com/jKjWg.png" alt="enter image description here"></p> <p>Here is the user database page (Worksheet 13):</p> <p><img src="https://i.stack.imgur.com/tkAWz.png" alt="enter image description here"></p> <p>On the user database page I would like it to add the two rows that dont exist (Music, Dance) and add the Sports tag weighting (-1) from the input page to the current value in user database page</p>
    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