mardi 28 novembre 2017

excel VBA if loop reading .74 as greater than .99?

So the problem is I am going through a range and if either of the cells offset to its right are greater than 99% (.99) it is to export that sheet and clear the information. For some reason it is not reading properly and from what I've seen any number higher than 50% it is exporting and clearing. I'm not sure what I have wrong but any help would be greatly appreciated!

Sub Export_loop()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

Dim Vol As Long
Dim Wght As Long
Dim LR As Long
Dim rng As Range
Dim rCell As Range

LR = Sheets("Summary").Range("B" & Rows.Count).End(xlUp).Row

Set rng = Sheets("Summary").Range("A2:A" & LR)

LR = Range("B" & Rows.Count).End(xlUp).Row

Sheets("Summary").Range("A2").Activate

Vol = ActiveCell.Offset(0, 7).Value
Wght = ActiveCell.Offset(0, 9).Value

For Each rCell In rng

If Vol > 0.99 Or Wght > 0.99 Then

Call Save_Out
    ThisWorkbook.Sheets(ActiveCell.Value).Activate
    Range("A3:N24").Clear
    Range("R3:R24").Clear
    Range("X3:X24").Clear

ThisWorkbook.Sheets("Summary").Activate
ActiveCell.Offset(1, 0).Select
    Vol = ActiveCell.Offset(0, 7).Value
    Wght = ActiveCell.Offset(0, 9).Value

Else

ActiveCell.Offset(1, 0).Select
    Vol = ActiveCell.Offset(0, 7).Value
    Wght = ActiveCell.Offset(0, 9).Value

End If

Next rCell

MsgBox "Exports Completed"

End Sub

Aucun commentaire:

Enregistrer un commentaire