Link to home
Start Free TrialLog in
Avatar of sandramac
sandramac

asked on

Paste Values

Hello all, I have this code below.  What I need iis a vba code that will find the value of the variable StrData in sheet13 column A, then if sheet5 cell a25 is not blank, then place an "X" in the matching row in Column H.

For example is StrData=KCTT, then in sheet 13, find KCTT, then check to see if sheet 5 cell a25 is not blank, if not blank then place an "X" on column H on the same row as KCTT.
Avatar of jnfsmile
jnfsmile
Flag of Israel image

You wrote you have code?...

Here is a subroutine you can use from your code. I hope it serves your needs.

Sub doMiracle(strData)
    Dim found As Range
    Set found = Sheets("Sheet13").Range("A:A").Find(strData)
    If Not found Is Nothing Then
        If Sheets("Sheet5").Range("A25") <> "" Then Sheets("Sheet13").Range("H" & Chr(64 + found.Row)).Value = "X"
    End If
End Sub

Open in new window

Avatar of sandramac
sandramac

ASKER

Hello I had to change a couple of values on the code but it will still not put the X, which I had to change to Pass here is what I have, it will not input the PASS when conditions are met

Dim found As Range
    Set found = Sheets("Sheet13").Range("A:A").Find(StrData2)
    If Not found Is Nothing Then
        If WS.Range("X44") <> "" Or WS.Range("X45") <> "" Then Sheets("Sheet13").Range("H" & Chr(64 + found.Row)).Value = "PASS"
    End If
Hello, tried to play around with the code but still having trouble, looking for some more help please.
Ok - we need to know if its actually finding anything, or if there's problem with setting the value.  If not finding anything, you'll note I've added a few more parameters to the find method - what <= is what you're looking for, lookIn <= xlValues (if a constant) or xlFormulas (if you're trying to find text in a formula),a nd finally, what might be the problem lookAt <= xlWhole looks for a whole word match (beware special characters in your spreadsheet!), and xlPart will search for the strData in the text and find a match if its contained in a cell in column A.

Or, your problem could be the Chr(64 + found.Row) = I've never seen this application before...

Column H same row would be sht.range("H" & found.row)!

I wrote the following with some adjustments to match your original question, but with your most recent post.  

Here's the code:
 
Sub findAndMark()
Dim found As Range
Dim WS As Worksheet
Dim findWS As Worksheet
Dim wkb As Workbook
Dim strData As String

    Set wkb = ActiveWorkbook
    Set WS = wkb.Sheets("Sheet5")
    Set findWS = wkb.Sheets("Sheet13")
    
    strData = "KCTT"
    
    Set found = findWS.Range("A:A").Find(strData)
    If Not found Is Nothing Then
        If WS.Range("X44") <> "" Or WS.Range("X45") <> "" Then
            findWS.Range("H" & found.Row).Value = "PASS"
        End If
    End If
    
End Sub

Open in new window

See attached.

Good luck!

Dave
findAndMark-r1.xls
Avatar of Jacques Geday
Hi Sandramac
Is this what your looking for ? Pls goto sheet 13 and activate the button Find in Sheet13 and Update Col H. Please enter any occurence and check the results.

Pls feel free to advise your comments.
gowflow
Paste-Values.xls
ASKER CERTIFIED SOLUTION
Avatar of Jacques Geday
Jacques Geday
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial