Need help...vlookup "type mismatch"

  • Thread starter Thread starter jeremy.haynie
  • Start date Start date
J

jeremy.haynie

So...my goal is to write a macro that will copy-paste values on all
cells in a selection that a vlookup returns a value > 0...and leave
the formula in the rest.

I get a type mismatch with the following code because of the vlookup
formula (even when a value is returned)

For Each cell In Selection
If cell.Value > 0 Then
cell.Copy
cell.PasteSpecial Paste:=xlValues
Next cell
Application.CutCopyMode = False



any suggestions?
 
For Each cell In Selection
if not iserror(cell) then
If cell.Value > 0 Then _
cell.formula = cell.Value
end if
Next cell
 

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