Clear Content based on another cell value (Empty)

gzell

New Member
Joined
Apr 20, 2019
Messages
37
Clear Content on Column C, D, E, based on cell G being empty and loop through worksheet
In sheet below, names would be cleared (column C, D, E, if Column G in same row is empty

Second item, is after column C, D, E are clear in row where empty cell is found,
then remove duplicate names in column C, D, E. If this should be on another thread, please let me know.
After this step, names in column C, D, E, would be cleared except for the names in row 917 and 950

Row_IDPerson_IDLast NameFirst NameMiddleData_IDResearch Data
91636BarberSilasH
91736BarberSilasH1_1ArmyConfederacy
91836BarberSilasH1_2LocationTexas
91936BarberSilasH1_3Regiment10th Regiment Texas Infantry (Nelson's)
92036BarberSilasH1_4FunctionInfantry
92136BarberSilasH1_5CompanyB
92236BarberSilasH1_6RankPrivate
92336BarberSilasH1_7Age38
92436BarberSilasH1_8Residence--
92536BarberSilasH1_9EnrolledSpringfield, Texas
92636BarberSilasH1_10DateOctober 10, 1861
92736BarberSilasH1_11EnlistedVirginia Point, Texas
92836BarberSilasH1_12DateOctober 23, 1861
92936BarberSilasH3_1DetailCommissary for Company
93036BarberSilasH3_1DetailFebruary, 1862
93136BarberSilasH3_1DetailMechanic
93236BarberSilasH3_1DateAugust 28, 1862
93336BarberSilasH8_1Returned to DutySeptember 1, 1862
93436BarberSilasH2_1CapturedArkansas Post, Arkansas
93536BarberSilasH2_1DateJanuary 11, 1863
93636BarberSilasH2_1ForwardedSt. Louis, Missouri via Boats
93736BarberSilasH2_1ForwardedCamp Douglas, Illinois via Rail
93836BarberSilasH2_1PrisonerCamp Douglas, Illinois
93936BarberSilasH2_1ParoledApril 1, 1863
94036BarberSilasH2_1Forwarded for Forward for ExchangeCity Point, Virginia
94136BarberSilasH2_1DateApril 7, 1863
94236BarberSilasH2_10HospitalGeneral Hospital
94336BarberSilasH2_10LocationPetersburg, Virginia
94436BarberSilasH2_10CauseDibilitas
94536BarberSilasH2_10AdmitedMay 7, 1863
94636BarberSilasH8_1Returned to DutyJune 16, 1863
94736BarberSilasH3_1DetailRegimental Clerk
94836BarberSilasH3_1DateApril 7, 1864
94937BarkerEnochW
95037BarkerEnochW1_1ArmyConfederacy
95137BarkerEnochW1_2LocationTexas
95237BarkerEnochW1_3Regiment10th Regiment Texas Infantry (Nelson's)
95337BarkerEnochW1_4FunctionInfantry
95437BarkerEnochW1_5CompanyE
95537BarkerEnochW1_6RankPrivate
95637BarkerEnochW1_7Age18
95737BarkerEnochW1_8Residence--
95837BarkerEnochW1_9EnrolledParker County, Texas
95937BarkerEnochW1_10DateOctober 12, 1861
96037BarkerEnochW1_11EnlistedHouston, Texas
96137BarkerEnochW1_12DateOctober 23, 1861
96237BarkerEnochW13_1DischargedCamp Yell, Arkansas
96337BarkerEnochW13_1DateMay 25, 1862
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
This will clear C:E where G is empty
VBA Code:
Sub gzell()
    With Range("G2:G" & Range("C" & Rows.Count).End(xlUp).Row)
        Intersect(.SpecialCells(xlBlanks).EntireRow, Range("C:E")).ClearContents
    End With
End Sub
After the above code is run, will there always be a blank row between different names?
 
Upvote 0
You're welcome & thanks for the feedback.

If you answer my question in post#2 I can help you with the rest.
 
Upvote 0
Yes there will be blank row between. This is a project I am researching for a Civil War Regiment that my Great Great Grandfather served.
 
Upvote 0
Ok, how about
VBA Code:
Sub gzell()
    With Range("G2:G" & Range("C" & Rows.Count).End(xlUp).Row)
        Intersect(.SpecialCells(xlBlanks).EntireRow, Range("C:E")).ClearContents
    End With
    With Range("E2", Range("C" & Rows.Count).End(xlUp))
      .SpecialCells(xlConstants).Offset(1).ClearContents
   End With
End Sub
 
Upvote 0
Solution
Thanks for the help. Worked great and now I can get back to cleaning up my entries and verifying data entries.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

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