Create macro on excel generated reports

aikiya22

New Member
Joined
Jun 23, 2014
Messages
6
Hi, excel masters. I don't know much about macros and VBA but I know that this can be done. if someone would be nice to help me, i would be tremendously grateful. Thank you

here's what I want to achieve,

1. I want to eliminate all texts that have "KM", "Litres", "Liters"
2. I want to eliminate all values under route length that is greater than 500
3. I want to have the sum of route length for each device because the current value for each device is not equal to actual sum
4. I want to do all this for every report with different set of data but has the same format

below is the link to the excel file. Thank you in advance




https://www.dropbox.com/s/me1qxkh4yb9wj2l/Travel Sheet Raw.xls?dl=0
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Unfortunately there appears to be a quota limit against your account and therefore that file is not accessible.
Have you another way to present this?
 
Upvote 0
I really don't know what your want as your linked sheet only has KMs mentioned down one column, nothing about Litres/Liters.

Maybe you need to redefine what you are seeking.
 
Upvote 0
Hi, thank you for the response.

I deleted most of the data because im only allowed to upload upto 1mb, the original file has cells that contains "litres" and "liters"

on column e, when you removed the "km" it will become number, when it is already number, i want it to add up and show the total in B326, B675 next to route length. every report has different sets of data, so it will not always be B326 and B675.

on column E, i just want to eliminate all values that is greater than 500. hope this makes it a little bit clear. thanks
 
Upvote 0
Hi, does this what you're after
Code:
Sub Drivers()

    Dim Ar As Areas
    Dim Rng As Range
    Dim Repl As Variant
    Dim Valu As Variant
    
    Repl = Array("km", "litres", "liters")
    For Each Valu In Repl
        Columns(5).Replace Valu, "", xlPart, , False, False, False
    Next Valu
    
    Set Ar = Columns(5).SpecialCells(xlConstants).Areas
    For Each Rng In Ar
        If Not Rng.Rows.Count = 1 Then
            With Rng.Offset(1).Resize(Rng.Count - 1)
                .Name = "a"
                Range("a") = Evaluate("if(a>500,0,a)")
                Range("B" & Rng.Offset(Rng.Count + 1).Row) = WorksheetFunction.Sum(.Value)
            End With
        End If
    Next Rng

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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