Finding specific data

dankar

Board Regular
Joined
Mar 23, 2016
Messages
113
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I have in my DB the fallowing :

Master & derivatives

COULMN
XXX-XXX-NUM-16-009 (MASTER) between the brackets for explination,its not included in the data
XXX-XXX-NUM-16-009 (MASTER) between the brackets for explination,its not included in the data
XXX-XXX-NUM-16-009C1 (derivatives) between the brackets for explination,its not included in the data
XXX-XXX-NUM-16-009C2 (derivatives) between the brackets for explination,its not included in the data
XXX-XXX-NUM-16-009C3 (derivatives) between the brackets for explination,its not included in the data
XXX-XXX-NUM-16-010
XXX-XXX-NUM-16-010
XXX-XXX-NUM-16-010C1
XXX-XXX-NUM-16-010C2
XXX-XXX-NUM-16-010C3
XXX-XXX-NUM-13-007C1
XXX-XXX-NUM-13-007C2
XXX-XXX-NUM-13-007C3

I have around 14000 row every master have derivatives (sometimes 1 derivative or 2 or 3 or more) and rarely without any derivative.

But its a must, if there is a derivative there should be Master.

My concern is to search and find if there is any derivative without master, to highlight the data with any C's which doesn't have the master

For example:

to highlight the fallowing or to extract the fallowing from the above example (the answer will be)

XXX-XXX-NUM-13-007C1
XXX-XXX-NUM-13-007C2
XXX-XXX-NUM-13-007C3

Thanks
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
try this

Code:
Sub hilite()
Dim c As Range, rng As Range
With ActiveSheet
Set rng = .Range("A2", .Cells(Rows.Count, 1).End(xlUp))
    For Each c In rng
        If Application.CountIf(rng, Left(c.Value, 18)) = 0 Then c.Interior.Color = vbYellow
    Next
End With
End Sub
 
Upvote 0
try this

Code:
Sub hilite()
Dim c As Range, rng As Range
With ActiveSheet
Set rng = .Range("A2", .Cells(Rows.Count, 1).End(xlUp))
    For Each c In rng
        If Application.CountIf(rng, Left(c.Value, 18)) = 0 Then c.Interior.Color = vbYellow
    Next
End With
End Sub

Thanks a lot for your reply...could you kindly explain how to use the code..I dont have an idea how to use codes (vba) in excel
 
Last edited:
Upvote 0
Thanks a lot for your reply...could you kindly explain how to use the code..I dont have an idea how to use codes (vba) in excel
Open the VB editor by pressing Alt + F11. Your file should be saved as a macro enabled workbook and your security settings should be set to allow access to VBA and run macros. Those are one time setting. If the large pane is dark then click Insert on the VB editor tool bar, then click Module. When the pane brightens, copy and paste the code into the pane and close the VB editor. You can then run the code by pressing Alt+F8 and double clicking the macro name.
 
Last edited:
Upvote 0
Thanks a lot it worked..

I have a sheet with around 15 columns..it worked if I deleted all the columns and kept the one I want to check, can we modify the code so I can use it without deleting any columns. The column that I need to work on is "D"

I tried to change the "A2" to "D2" but when I run the macro it takes longer time and then not responding,


thanks again for your help
 
Upvote 0
Thanks a lot it worked..

I have a sheet with around 15 columns..it worked if I deleted all the columns and kept the one I want to check, can we modify the code so I can use it without deleting any columns. The column that I need to work on is "D"

I tried to change the "A2" to "D2" but when I run the macro it takes longer time and then not responding,


thanks again for your help

You have to make a change in two places to change columns, see blue font in code below. This should work for you

Code:
Sub hilite()
Dim c As Range, rng As Range
With ActiveSheet
Set rng = .Range("[COLOR=#0000cd]D2[/COLOR]"[COLOR=#0000cd], [/COLOR].Cells(Rows.Count,[COLOR=#0000cd] 4[/COLOR]).End(xlUp))
    For Each c In rng
        If Application.CountIf(rng, Left(c.Value, 18)) = 0 Then c.Interior.Color = vbYellow
    Next
End With
End Sub

The 4 is the column number, but you can use the alpha column designation enclosed in quotes, i.e. "D" in this case.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,800
Members
449,468
Latest member
AGreen17

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