+ Reply to Thread
Results 1 to 3 of 3

Check for data in cell. If found paste text into same row another column

Hybrid View

  1. #1
    Registered User
    Join Date
    05-04-2009
    Location
    San Diego, California
    MS-Off Ver
    Excel 2003
    Posts
    43

    Check for data in cell. If found paste text into same row another column

    I am trying to create a code that will check N12 for data. If found then I would like to enter the text “Right Here” into M12. Here is the code I am using but once I put it into VBA the third line of this block gets highlighted in red. Can you help me to get this working right?

    Dim I As Long
    Dim R As Long
    I = ActiveSheet.Cells(Rows.Count, "N12").End(xlUp).Row
    For R = 2 To I
    With Cells(R, "N12")
    If .Text Like "<>" Then
    Cells(R, "M12") = "Right Here"
    End If
    End With
    Next R
    Last edited by Buddy7; 06-11-2011 at 02:38 PM. Reason: SOLVED

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Check for data in cell. If found paste text into same row another column

    Hi Buddy7


    Try...
    Sub ptest()
        Dim c
        Dim firstAddress
        With ActiveSheet.Range("A1", Cells(Rows.Count, 1).End(xlUp))
            Set c = .Find(.Range("N12").Value, Lookin:=xlValues)
            If Not c Is Nothing Then
                firstAddress = c.Address
                Do
                    c.Offset(0, -1).Value = "Right Here"
                    Set c = .FindNext(c)
                Loop While Not c Is Nothing And c.Address <> firstAddress
            End If
        End With
    End Sub
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Registered User
    Join Date
    05-04-2009
    Location
    San Diego, California
    MS-Off Ver
    Excel 2003
    Posts
    43

    SOLVED: Check for data in cell. If found paste text into same row another column

    Hi Pike,

    This is perfect. Thank you!
    Last edited by Buddy7; 06-11-2011 at 02:38 PM. Reason: SOLVED

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1