0% found this document useful (0 votes)
4 views1 page

Excel Volume Scanner Macro Guide

The document contains a VBA macro named 'VolumeScanner' that scans a worksheet to copy volume data from Column D to Column E on the first run. It then calculates the difference between the current volume and the initial volume in Column F, sorts the data by this difference in descending order, and updates the worksheet. The macro is set to run again every 5 seconds.

Uploaded by

aaryinfo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Excel Volume Scanner Macro Guide

The document contains a VBA macro named 'VolumeScanner' that scans a worksheet to copy volume data from Column D to Column E on the first run. It then calculates the difference between the current volume and the initial volume in Column F, sorts the data by this difference in descending order, and updates the worksheet. The macro is set to run again every 5 seconds.

Uploaded by

aaryinfo
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

Dim initialScanDone As Boolean

Sub VolumeScanner()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long

Set ws = [Link](1) ' Adjust if needed

' Find last row with data


lastRow = [Link]([Link], "B").End(xlUp).Row

[Link] = False

' On first run, copy Column D (volume) to Column E (initial volume)


If Not initialScanDone Then
For i = 2 To lastRow
[Link](i, 5).Value = [Link](i, 4).Value
Next i
initialScanDone = True
End If

' Calculate difference in Column F (volume - initial_volume)


For i = 2 To lastRow
[Link](i, 6).Value = [Link](i, 4).Value - [Link](i, 5).Value
Next i

' Sort by Column F (descending)


With [Link]
.[Link]
.[Link] Key:=[Link]("F2:F" & lastRow), Order:=xlDescending
.SetRange [Link]("A1:F" & lastRow)
.Header = xlYes
.Apply
End With

[Link] = True

' Run again after 5 seconds


[Link] Now + TimeValue("00:00:05"), "VolumeScanner"
End Sub

You might also like