VBA/Data Validation/Conditional Formating?

JMacd

New Member
Joined
Apr 11, 2019
Messages
1
Hello,
I appreciate you taking the time to look at my problem. Ineed some help in a couple of areas.
I have about 6 workbooks, all with 20-70+ worksheets withinthem all correlating to different areas we work in.

They are all laid out the same with column E detailingdifferent lamp types we use eg. 70w SON, 35w SOX, 19w LED etc etc, there are about20 lamp types I have on my list currently. I will need to be able to keepupdating everything to add in new lamp (or delete) as the changes happen.

I have a totals page of this so we can keep track of howmany lamps we have in each area however things change, people change lamps allthe time without telling us and people update the spreadsheets without checkingif it is a new lamp type, not currently listed.

This is work I have adopted from someone else, so I am notsure if there is anything that has been already added that is not listed.

I know I can use conditional formatting for it to highlightcells that contain the lamps (therefor letting me see non-highlighted for me toknow they need adding to the totals page) however, I would have to do this foreach sheet, there are a lot, it would take a very long time. Is there a VBA wayaround this please that I can run on the sheet, and then be able to take it offagain so all cells clear of their colour when I have run the check?

Also, is there a way I can add a warning in, so if anythingthat is added into column E in future, that is not apart of the list, it comesup with a warning to add this in. I know I can do this through data validation,but I cannot get it to apply to the whole workbook causing the same problemwith conditional formatting.

Many thanks.



 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
An alternative for you to consider
-get VBA to update the list if user introduces a new type of lamp

This simplified example assumes that
- each workbook has a sheet named "ListOfLamps"
- with current list of lamps in column A
- (that list is periodically updated from a master list)
- when use enters data in column E of an Area sheet, VBA checks to see if the lamp type already exists
- the user is allowed to enter a new type of lamp in column E (but see NOTE below)
- the new type is auto-added to the list in sheet ListOfLamps
- the warning is that NEW is added in column B

The macro to do that is very simple and goes in ThisWorkbook module of each workbook
Code:
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
[COLOR=#006400][I]'exclude any sheets that are not Area sheets[/I][/COLOR]
    If Sh.Name = "ListOfLamps" Then Exit Sub
    If Sh.Name = "Tables" Then Exit Sub
[I][COLOR=#006400]'which sheet contains the list and where[/COLOR][/I]
    Dim ws As Worksheet: Set ws = Sheets("ListOfLamps")
    Dim LampList As Range: Set LampList = ws.Columns("A")
[I][COLOR=#006400]'if anything is entered in column E in any of the non-excluded sheet do this[/COLOR][/I]
    If Not Intersect(Target, Sh.Columns("E")) Is Nothing Then
        If WorksheetFunction.CountIf(LampList, Target) = 0 Then
[I][COLOR=#006400]        'line below adds the item to the list if not already there, flagging it as new[/COLOR][/I]
            ws.Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(, 2) = Array(Target, "NEW")
        End If
    End If
End Sub
NOTE
Obviously needs enhancing to better control what is added
- user to confirm that it is a genuine new type
- verify against master list
- perhaps further authorisation required ??
etc
 
Last edited:
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