Excel VBA - Delete cell to right of cell

  • Thread starter Thread starter MAYDAY
  • Start date Start date
M

MAYDAY

Hello,

I have a spreadsheet and in one column there are several values.
need a macro that will search column A and if a value exists, I wan
the contents in the cell to the right of that cell to be deleted.

Thanks in advance for the help
 
Assume the values are hard coded (not produced by formulas) I understood
you to want to clear regardless of the value, rather than for a specific
value. If the latter, post back.

if Application.CountA(columns(1)) <> 0 then
set rng = Intersect(columns(1).SpecialCells(xlConstants).EntireRow, _
Columns(2))
rng.ClearContents
End if
 
Thanks Tom,

I apologize for not being more clear. What I'm trying to do is this:

If there is a cell in column A that has a value of 'abc'(hard coded, n
formulas), I want the contents in the cell to the right to be deleted
 
dim rng as Range, cell as Range
if Application.CountA(columns(1)) <> 0 then
set rng = Intersect(columns(1).SpecialCells(xlConstants).EntireRow, _
Columns(2))
for each cell in rng
if lcase(cell.Value) = "abc" then
cell.offset(0,1).ClearContents
end if
NExt
End if
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top