0

i have the following code:

.AutoFilter Field:=3, Criteria1:=docnum
    .AutoFilter Field:=6, Criteria1:=pmtdate

  
    Range("H1").Select
    Selection.Offset(1, 0).Select
     Range(Selection, Selection.End(xlDown)).Select
     visibleTotal = Application.WorksheetFunction.Sum(Selection.SpecialCells(xlCellTypeVisible))
     
     
     
     If visibleTotal = pmtamt Then
     

     MsgBox visibleTotal

so, my issue is i want it to accept the visible total with a range of (up to +-10) .

for example if my variable is = 10 i want my code to match everything from 0 to 20 with a margin of + or - 10 numbers from my variable

so everything between 0 and 20 should be matched including 10.001 and 10.569... ETC..

i'm doing this to match amounts regardless of currency differences that might raise the amount or decrease it and my allowed range is + or - 10 $

let me know if my question isn't clear.

Warcupine
  • 4,460
  • 3
  • 15
  • 24
  • You might benefit from reading [How to avoid using Select in Excel VBA](https://stackoverflow.com/questions/10714251/how-to-avoid-using-select-in-excel-vba). – Pᴇʜ Sep 09 '21 at 12:49
  • 1
    Its unclear exactly what you are trying to do. Do you just need to adjust your autofilter to filter between variable-10 and variable+10? – Jody Highroller Sep 09 '21 at 12:51

0 Answers0