Help with Categorize Rows based on multiple conditions , VBA/ Excel Formula

firstlovecity

New Member
Joined
Sep 8, 2015
Messages
1
I have uploaded what my current sheet look like and what is my goal.
-Sheets are categorized by Road ID and are ordered increasingly.
- Every row is identified by Road ID, Start meter and End Meter
- Each row indicates data (Road Id, Start,End,Lane,Speed,Event 1 and more which I trimmed at this stage) for 10 meter section of Road ID from Start to End

My goal is categorize all consequent 10 meter data for Same Road Id.

Example:
Road Id 2011 start from 390 end 400 then Next row it continues from 400 to 410, then 410 to 420 and last is 420 to 430
I want these 4 rows which are consequent be categorized as 2011-A and next two rows which start from 1480 end 1490, then 1490 to 1500 categorized as
2011-B

I tried to solve with without VBA coding and sets of nested IF,conditional formatting however its still not my desire goal.
here is link to image if you are not able to see the image here.
http://s18.postimg.org/6r1ylfnqh/Excell_QA.jpg

appreciate for your help and guidance in advance


Excell_QA.jpg
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hope this helps.

Code:
Sub firstlovecity()
Dim i As Long, j As Long, LastR As Long, cnt As Long, str As String
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Worksheets("Current Data")
Set ws2 = Worksheets("GOAL")
With ws1
    LastR = .Cells(Rows.count, 1).End(xlUp).row
    For i = 3 To LastR
        If .Cells(i, 1).Value <> .Cells(i - 1, 1) Then
            ws2.Cells(i, 1).Value = .Cells(i, 1).Value & "-A"
            j = 1
        Else
            If .Cells(i, 2).Value = .Cells(i - 1, 3).Value Then
                ws2.Cells(i, 1).Value = ws2.Cells(i - 1, 1).Value
            Else
                j = j + 1
                str = Split(Cells(1, j).Address, "$")(1)
                ws2.Cells(i, 1).Value = .Cells(i, 1).Value & "-" & str
            End If
        End If
    Next
End With
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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