Results 1 to 6 of 6

Thread: CustomerAccounts !! HELP Control and Logic Loops

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Sep 2017
    Posts
    7
    Location
    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
       rngData = .Range("A4", .Range("A10000").End(xlUp)) -  I still do not know what I am doing wrong - this one is showing an error 
    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 Tommy; 09-18-2017 at 10:03 AM. Reason: Wrapped with code tags + took out the unnecessary stuff

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
  •