Results 1 to 6 of 6

Thread: CustomerAccounts !! HELP Control and Logic Loops

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    The Code in Question
    Option Explicit
    Dim wsData As Worksheet
    Dim wsResults As Worksheet
    Dim rngData As Range
    Dim custID As String
    Dim amtOwed As Integer
    Dim refData As Range
    Dim refAns As Range
    Dim noAns As Integer
    
    Sub AmountOwed()
    With wsData
        Set rngData = .Range("A4", .Range("A10000").End(xlUp))
    End With
    For Each refData In rngData.Cells
        amtOwed = refData.Offset(0, 1) - refData.Offset(0, 2)
        If amtOwed > 1000 Then
            custID = refData
            refAns = custID
            refAns.Offset(0, 1) = amtOwed
            Set refAns = refAns.Offset(1, 0)
            noAns = noAns + 1
        End If
    Next
    With wsResults
        .Range("A3").Resize(noAns, 2).Sort .Range("B4"), xlDescending, .Range("A4"), , xlAscending, , , xlYes
    End With
    End Sub
    Last edited by Aussiebear; 12-13-2024 at 03:00 PM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •