VBA - Cannot capture the decimal places

hellfire45

Active Member
Joined
Jun 7, 2014
Messages
464
So I have a spreadsheet where I need to capture the rows with values that are less than $1 in a specific column.

In the spreadsheet a number of rows say $0.80 in said column which means it needs to be captured.

The below code runs through every line in the spreadsheet and amongst other things captures the CHG_AMT which is the variable I spoke up. Then below it says ElseIf CHG_AMT < 1 Then, do something. However, the CHG_AMT is being captured in the locals window as 1.

I tried using variant, double, using Round(blah blah, 2), and nothing has worked. Any ideas guys? Thank you very kindly.


Code:
For X_ROW = 2 To LAST_ROW                        On Error GoTo nextfile:
                        Application.StatusBar = "Parsing Data: " & Format(X_ROW / WorksheetFunction.CountA(.Columns(DEV_ID)), "0.0%")
                        CHG_AMT = Round(.Cells(X_ROW, CHARGE_AMT).Value, 2)
                        CUSTOMER = .Cells(X_ROW, CUST_NAME).Value
                        DEVICE_ID = .Cells(X_ROW, DEV_ID).Value
                        BLACKLIST_CUSTOMER = WorksheetFunction.IfError(Application.Match(CUSTOMER, BLACK_LIST, 0), 0)
                        PAST_ITEM_CHECK = WorksheetFunction.IfError(Application.Match(DEVICE_ID, PAST_ITEMS, 0), 0)
                        
                        If X_ROW > 1348 Then
                            MsgBox "Stop"
                        End If
                        
                        
                        If PAST_ITEM_CHECK > 0 Then
                                                Prev_List_LR = Prev.Columns(DEV_ID).Find("*", , , , xlRows, xlPrevious).Row
                                                .Rows(X_ROW).Copy Destination:=Prev.Rows(Prev_List_LR + 1)
                                    
[B]                                    ElseIf CHG_AMT < 1 Then[/B]
                                                Under_One_LR = UnderONE.Columns(DEV_ID).Find("*", , , , xlRows, xlPrevious).Row
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
How is CHG_AMT declared? It should be Double or Currency,
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,190
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top