• Range Syntax (2000)

    Author
    Topic
    #376916

    Nevermind, I got it. Problem was not with the Range definition, but with a loop I had in the rest of my code which cut out after the first cell. Thanks!

    Viewing 0 reply threads
    Author
    Replies
    • #619096

      In the code excerpt below I am ensuring that if the user enters a credit invoice, all of the entries in the same row are negative.

      For Each cell In ThisWorkbook.Sheets("Journal").Range("b8:b64")
          If cell.Value = "PFC Credit Memo" Or cell.Value = "Pilgrims Credit Inv" Then
              For Each cellr In ThisWorkbook.Sheets("Journal"). _
                  Range(Cells(cell.Row, 4), Cells(cell.Row, 15))
                    If cellr.Value > 0 Then cellr.Value = cellr.Value - (cellr.Value * 2)
              Next
          End If
      Next
      

      However, the last part of the Range definition in red above does not seem to take all the way out to the end of the row.
      Actually, the first cellr (cell.Row, 4) changes, but the rest of the Range does not. How do I refer to the Range to make
      it take each cellr in the entire Range?

      • #619139

        I am not sure what you need or what the problem is could you give more details>

        The code in red checks in:
        Cols D – O in rows that have either a row that that PFC Credit Memo or Pilgrims Credit Inv in Col B

        If the value in the cell is > 0 it subtracts double the current value from it. (why don’t you just use “-cellr.value”?) and then goes to the next cell.

        Steve

    Viewing 0 reply threads
    Reply To: Range Syntax (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: