Clear cell contents of non highlighted cells in a range

Serafin54

Board Regular
Joined
Apr 11, 2014
Messages
165
Office Version
  1. 2016
Platform
  1. Windows
Hello, I have an audit program that shows me differences between two excel files. It highlights the differences depending on what the difference relates to. I then later need to figure out the amount of changes on the target file (which i already had help accomplishing) per row and then import the changes only into our system. What i am hoping to have help doing is clearing, not deleting, any cell in a range (ending at the last line of data) that is not highlighted. Ultimately, it'd be awesome to be able to tell the code what the "key" columns are, since they wouldn't all be highlighted and clear anything outside those columns but i'd right now settle for selecting all the columns outside of the keys manually at this point as it's been all manual. Below is a sample of a file. Thank you!

Target Employee Master results.xlsx
ABCDEFGHIJKLMNOPQR
1eecodeeestatdesceestatusclockdescclockseqdepartmentdescdepartmentcodejobsdescjobscodeprojectscodepositiongenderethnicityeeocemploymentpensionplnsalaryrate_1
22233EE StatusTerminatedAdmin100Food Service WorkerFSW20-7850FemaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0011.30
31682EE StatusActiveOps200Food Service WorkerFSW20-7852MaleBlack or African AmericanService WorkersFull TimeNo0.0018.00
4A05TEE StatusTerminatedAdmin100JanitorJTR20-7850MaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0014.05
55649EE StatusTerminatedAdmin100Food Service WorkerFSW20-7850MaleHawaiian or Pacific IslanderNot ProvidedNot ProvidedNo0.0011.30
65328EE StatusActiveOps200CookCK20-7852MaleHispanic or LatinoService WorkersFull TimeNo0.0021.00
78588EE StatusTerminatedAdmin100Food Service WorkerFSW20-7850FemaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0011.30
8A02YEE StatusActiveOps200JanitorJTR20-7852FemaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0018.00
9A02ZEE StatusTerminatedAdmin100Food Service WorkerFSW20-7850FemaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0011.30
100541EE StatusTerminatedOps200Food Service WorkerFSW20-7851FemaleHispanic or LatinoService WorkersFull TimeNo0.009.91
110981EE StatusTerminatedAdmin100Food Service WorkerFSW20-7850MaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0011.30
121421EE StatusTerminatedOps200Food Service WorkerFSW20-7851MaleHispanic or LatinoService WorkersFull TimeNo0.009.91
136000EE StatusTerminatedOps200Food Service WorkerFSW20-7851MaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0016.09
14A05SEE StatusActiveAdmin100Office ManagerOFE20-7850FemaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0020.00
153859EE StatusActiveOps200Food Service WorkerFSW20-7852MaleHispanic or LatinoService WorkersFull TimeNo0.0018.00
164390EE StatusTerminatedAdmin100CookCK20-7850MaleWhiteNot ProvidedNot ProvidedNo0.0014.30
176375EE StatusTerminatedAdmin100CookCK20-7850FemaleWhiteNot ProvidedNot ProvidedNo0.0015.00
18A01F* 1099 status *InactiveAdmin100CookCK20-7850FemaleNot ProvidedNot ProvidedNot ProvidedNo0.0015.00
193502EE StatusActiveOps200Food Service WorkerFSW20-7852FemaleTwo or more racesNot ProvidedNot ProvidedNo0.0018.00
207640EE StatusTerminatedOps200Food Service WorkerFSW20-7851MaleBlack or African AmericanService WorkersFull TimeNo0.009.91
21A057EE StatusActiveOps200Food Service WorkerFSW20-7852MaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0018.00
22A05PEE StatusTerminatedAdmin100Office ManagerOFE20-7850FemaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0020.00
230129EE StatusTerminatedOps200Food Service WorkerFSW20-7851MaleWhiteNot ProvidedNot ProvidedNo0.009.91
248857EE StatusTerminatedOps200Food Service WorkerFSW20-7851FemaleHispanic or LatinoNot ProvidedNot ProvidedNo0.009.91
257604EE StatusActiveOps200CookCK20-7852MaleBlack or African AmericanService WorkersFull TimeNo0.0021.00
261238EE StatusTerminatedAdmin100JanitorJTR20-7850MaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0014.05
279541EE StatusActiveOps200Food Service WorkerFSW20-7852MaleHispanic or LatinoService WorkersFull TimeNo0.0018.00
28A02PEE StatusTerminatedAdmin100CookCK20-7850MaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0014.30
296214EE StatusTerminatedOps200Food Service WorkerFSW20-7851MaleHispanic or LatinoNot ProvidedNot ProvidedNo0.0011.30
303654EE StatusTerminatedOps200Food Service WorkerFSW20-7851FemaleTwo or more racesNot ProvidedNot ProvidedNo0.0011.30
313640EE StatusActiveAdmin100Administrative AssistantADM20-7852FemaleWhiteNot ProvidedNot ProvidedNo2,400.000.00
32A01G* 1099 status *TerminatedAdmin100Food Service WorkerFSW20-7850UnspecifiedNot ProvidedNot ProvidedNot ProvidedNo0.0010.00
336373EE StatusTerminatedAdmin100CookCK20-7850MaleWhiteNot ProvidedNot ProvidedNo0.0014.30
343574EE StatusActiveOps200Food Service WorkerFSW20-7852MaleBlack or African AmericanService WorkersFull TimeNo0.0018.00
353079EE StatusActiveOps200Food Service WorkerFSW20-7852FemaleHispanic or LatinoService WorkersFull TimeNo0.0018.00
365340EE StatusActiveOps200Food Service WorkerFSW20-7852FemaleHispanic or LatinoService WorkersFull TimeNo0.0018.00
37A030EE StatusTerminatedAdmin100CookCK20-7850FemaleBlack or African AmericanNot ProvidedNot ProvidedNo0.0014.30
388937EE StatusTerminatedOps200Food Service WorkerFSW20-7851MaleAm. Indian or Alaskan NativeService WorkersFull TimeNo0.009.91
Report
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I thought this might do the trick but i am getting a run-time error with Object Required on the Interior.Color line.

VBA Code:
Sub Clear()
    Dim rng As Range
    For Each rng In Selection
    If Cell.Interior.Color = 0 Then
        Cell.ClearContents
    End If
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

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