PDA

View Full Version : [SOLVED:] If a cell contains #N/A then copy paste end of row



Nicolaf
04-22-2014, 10:50 AM
Hi,

I need a macro that if cell C2 in sheet Data is equal to #N/A then it should copy value in cell B2 (of sheet Data) and copy it onto sheet Database at the end of row B (both sheets Data and Database are in same workbook).

How do I do that?

:think:

Kenneth Hobs
04-22-2014, 11:58 AM
I don't know what end of row B means. If you mean end of column B:

If WorksheetFunction.IsNA(Worksheets("Data").Range("C2")) Then _
Worksheets("Data").Range("B2").Copy Worksheets("Database").Range("B" & Rows.Count).End(xlUp).Offset(1)

ashleyuk1984
04-22-2014, 12:08 PM
Here's my take.


Sub Ash_NA()

If IsError(Sheets("Data").Range("C2").Value) Then
If Sheets("Data").Range("C2").Value = CVErr(xlErrNA) Then
Sheets("Data").Range("B2").Copy
Sheets("Database").Range("B" & Rows.Count).End(xlUp).Offset(1, 0).PasteSpecial xlPasteValues
End If
End If


End Sub

I'm not quite as experienced as the others :P lol

Nicolaf
04-23-2014, 01:06 AM
Yes it was end of column.

Thanks exactly what I needed!

:hi::hi: