Find Cell and clear contents

Lazerus3511

New Member
Joined
Apr 5, 2015
Messages
15
Greetings all,

I have been using this site for my VBA needs for a couple months now, but this is the first time I've needed to post! I am having trouble with something that I think would be pretty easy and my Record Macro button isn't catching it for some reason. I appreciate in advance you taking the time to review this and your guidance.

I would like to start off by saying that I am just starting out with VBA!

So here is what I got going on so far:
This finds blank cells in the active worksheet in C and deletes the row. I would like to add a second part to it that which looks in A and B to find cells that say "no work" or "none" (not case sensitive) and clears the contents of that cell.
It would also be pretty cool to have this Macro check just a range of Row 4:1000, but that is not a necessity.

Code:
Sub BuildInventory()


Dim iRow As Long
Dim LastRow As Long


' This macro deletes all Blank rows on the active worksheet
' that have no value in column A.
LastRow = ActiveSheet.UsedRange.Rows.Count + ActiveSheet.UsedRange.Row - 1
For iRow = LastRow To 1 Step -1
If Cells(iRow, 3) = "" Then Rows(iRow).Delete
Next iRow
' Finished Deleting blanks.


' Now I would like to add something that finds "no work" or "none" in Column A and B and clearcontents here'


' Finished clearing No Work and none




End Sub

Thanks again all!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Code:
Range("A4:B4000").Replace What:="No Work", _
                          Replacement:="", _
                          LookAt:=xlWhole, _
                          MatchCase:=[color=darkblue]False[/color]
                          
Range("A4:B4000").Replace What:="none", _
                          Replacement:="", _
                          LookAt:=xlWhole, _
                          MatchCase:=[color=darkblue]False[/color]
 
Upvote 0
For a fixed range line A4:B1000, you can do it with a single line of code...
Code:
[A4:B1000] = [IF(LEN(A4:B1000),IF((A4:B1000="No Work")+(A4:B1000="none"),"",A4:B1000),"")]
 
Upvote 0

Forum statistics

Threads
1,215,436
Messages
6,124,869
Members
449,192
Latest member
MoonDancer

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