How to change cell colors when another cell is affected

samk379

New Member
Joined
Nov 8, 2024
Messages
16
Office Version
  1. 2021
Platform
  1. Windows
I'm working on setting up a work order tracking system for a small shop. I was able to get to the point where an order is scanned and then the location is scanned and that data is inputted into a table (the two-column table on the right side of the sheet). I also have another table set up that is a better visual measure of progress. If order THD0001 is at the WELD2 station, for example, the cell at the intersection of the THD0001 row and the WELD2 column fills green. Right now, when the order moves along to the next step, it blanks the previous cell and fills in the cell of the new location. Is there a way I can make it so that the previous cell fills in black so that we could see which orders required which steps? In other words, if the order goes from WELD2 to ASSEMBLY, the cell for WELD2 is filled black.
I am also wondering if there is a way that when an order is scanned as complete, the date and/or time of that scan shows in the COMPLETE column, but this is less important to the system function.

Any help would be greatly appreciated, thank you!
Work Order Status Sheet.xlsm
ABCDEFGHIJKLMNOPQRSTUV
1Barcode Reader
2
3Order
4Location
5
6
7OrderDateDue DateDEBURRCNCPLASMAPRESSBRAKESAWLATHE1LATHE2MACHININGDRILLTACKWELD1WELD2GRINDPAINTASSEMBLYCOMPLETEOrderLocation
8TFD0012TFD0012CNCPLASMA
9CHD0036CHD0036SAW
10GD0009GD0009MACHINING
11LE0012LE0012DEBURR
12HK0001HK0001DEBURR
13THD0001THD0001WELD2
Reader
Cell Formulas
RangeFormula
B8:B13B8=U8
Named Ranges
NameRefers ToCells
Orders=OrdersTable[Order]B8
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E8:S1612Expression=VLOOKUP($B8,$U:$V,2,0)=E$7textNO
E8:S1612Expression=COLUMN()<MATCH($V8,$A$7:$S$7,0)textNO
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Add this code to the sheet module, in my case I named it Summary

How do you get the OrderNum and OrderLoc cells to populate the values you want from the barcode?

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim i As Range
 
  Set i = Intersect(Range("BarcodeScan"), Target)
  If Not i Is Nothing Then
    If Range("OrderNum").Value <> "" And Range("OrderLoc").Value <> "" Then
      AddNewOrderToDB
    End If
  End If
 
End Sub
A code would be scanned once that would translate to the order number and be input into B3, and then the code for the location would be scanned and input into B4. We just use Code39 barcodes, so scanning basically works the same as typing in the order number and location into those cells
 
Upvote 0
I think your going to have a problem then. I think your going to need a different barcode cell for the Order number and the order location

The auto macro is going to try to add new values to the DB after any entry into the BarcodeScan cell

This is how I see it. You have a barcode next to the OrderNum cell. Once that cell is populated, an event macro moves the cell to the Order location barcode cell and waits for the next barcode. Once the barcode for the Order location has been entered, the macro then adds the values to the DB. Make sense?
 
Upvote 0
You need a table to convert the barcodes to the correct values so we can add formulas in the OrderNum and OrderLoc cells. That way you don't to interpret them manually
 
Upvote 0
I think your going to have a problem then. I think your going to need a different barcode cell for the Order number and the order location

The auto macro is going to try to add new values to the DB after any entry into the BarcodeScan cell

This is how I see it. You have a barcode next to the OrderNum cell. Once that cell is populated, an event macro moves the cell to the Order location barcode cell and waits for the next barcode. Once the barcode for the Order location has been entered, the macro then adds the values to the DB. Make sense?
Right now, there is a macro that puts the first scan in B3, then the cell moves to B4 for the location, and then that information is put into a table showing the current location for that order. There is no BarcodeScan cell
 
Upvote 0
Here is an example

SAMk379 Barcode Reader.xlsm
ABC
1ValueBarcode
2Order Number:
3Location:
Summary


VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim i As Range
  
  Set i = Intersect(Range("OrderNumBC"), Target)    'Move cell to Order Locatin Barcode
  If Not i Is Nothing Then
    Range("OrderLocBC").Select
    Exit Sub
  End If
  
  
  Set i = Intersect(Range("OrderLocBC"), Target)    'Add values to DB
  If Not i Is Nothing Then
    If Range("OrderNum").Value <> "" And Range("OrderLoc").Value <> "" Then
      AddNewOrderToDB
    End If
    Exit Sub
  End If

End Sub
 
Upvote 0
Can you show me an example of one of the barcodes
I made a Video that shows how this process works. I typed the codes in instead of scanning the barcodes, but the process is the same when scanning, since the scanner essentially works as a text input device. The codes are just the order number/location in Code39 font so that they are scannable. In other words, the code for MACHINING is "MACHINING". You can see that when I input the order and the location, that information is updated in the table on the right side. Excel Demo
 
Upvote 0
Well, the video wasn't as valuable, but your description was good. Based on that, you have one barcode for Order number and one for order location. My last post should help with that.

At the beginning, the active cell is Order Number. You scan a code for that and the macro moves focus to Order Location. You scan another code and the macro delivers the new set of data to the DB table, erases the last values and selects the Order Number again to start the process all over.

I altered the code below

Put this in a standard module
VBA Code:
Sub AddNewOrderToDB()

  Dim Cel As Range
  Dim OrderRng As Range
  Dim OrderNum As String
  Dim OrderLoc As String
  
  OrderNum = Sheets("Summary").Range("Ordernum").Value
  OrderLoc = Sheets("Summary").Range("Orderloc").Value
  
  Set OrderRng = Sheets("DB").Range("OrderHist_Tbl[Order]")
  Set Cel = OrderRng.Resize(1, 1).Offset(OrderRng.Rows.Count, 0)
  Cel.Value = OrderNum
  Cel.Offset(0, 1).Value = OrderLoc
  Cel.Offset(0, 2).Value = Now()
  
  Sheets("Summary").Range("Ordernum").Value = ""
  Sheets("Summary").Range("Orderloc").Value = ""
    
  Sheets("Summary").Range("OrderNum").Select
  
  
End Sub

Replace any code you had for the Summary sheet with this
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim i As Range
  
  Set i = Intersect(Range("OrderNum"), Target)    'Move cell to Order Location
  If Not i Is Nothing Then
    Range("OrderLoc").Select
    Exit Sub
  End If
  
  
  Set i = Intersect(Range("OrderLoc"), Target)    'Add values to DB
  If Not i Is Nothing Then
    If Range("OrderNum").Value <> "" And Range("OrderLoc").Value <> "" Then
      AddNewOrderToDB
    End If
    Exit Sub
  End If

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
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