• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Pick the left cell value if N/A found on Right cell.

Nishu

New Member
I have a data where if #n/a found on 2nd cell, then 1st cell value will replace the 2nd cell value. below code is working fine but whenever any blank value is in 1st cell code skip that steps and #n/a remains as it is.
Please assist

Code:
Sub NAFILL()
For Each r In Columns(1).SpecialCells(2)
If InStr(r.Offset(0, 1).Text, "#N/A") > 0 Then
r.Offset(0, 1).Value = r.Value
End If
Next r
End Sub
 

Attachments

  • NAFILL.xlsm
    18.5 KB · Views: 2
Last edited by a moderator:
Why are you not checking in column 2 directly?

Code:
Sub NAFILL()
For Each r In Columns(2).SpecialCells(2, 16)
  If InStr(r.Text, "#N/A") > 0 Then
  r.Value = r.Offset(0, -1).Value
  End If
Next r
End Sub
Yes, you are right. We can also do same from Column 2, Just one qs. what exact "SpecialCells(2, 16)" is doing ?
 
Yes, you are right. We can also do same from Column 2, Just one qs. what exact "SpecialCells(2, 16)" is doing ?
Hi ,

While you are in the Visual Basic Editor screen , just press F1 to bring up the Help system , and enter SpecialCells ; you can check out the help on :

Range.SpecialCells Method

Narayan
 
Back
Top