Posts by muggi

    hi there,
    Im trying to get this formula in Excel by a VBA code.


    =(H6<>"")*(COUNTIF($A$9:$D$78;H6)=0)


    Code
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=(H6<>"")*(COUNTIF($A$9:$D$78;H6)=0)"
        Selection.FormatConditions(Selection.FormatConditions.Count).SetFirstPriority
        With Selection.FormatConditions(1).Interior
            .PatternColorIndex = xlAutomatic
            .ColorIndex = 39
            .TintAndShade = 0
        End With
        Selection.FormatConditions(1).StopIfTrue = True


    The problem the is the vba wont run with the formula
    the error i get is this:


    Runtime error '5'
    invalid procedure call or argument


    The formula works in excel and the conditional format area when its written as this:
    =(H6<>"")*(COUNTIF($A$9:$D$78;H6)=0)


    Any way to get this formula to work ?

    Re: VBA: Worksheet_Change(ByVal Target As Range) in 2 cells + copy and paste to 2 Col


    Sorry, didn't know the reason for posting links when crossposting..


    here is the final solution:


    Re: VBA: Worksheet_Change(ByVal Target As Range) in 2 cells + copy and paste to 2 Col


    You are right, I just explained the problem in the other forum.
    It would be a good idea to only get a match on the whole cell and not just a part of it.


    But here is link to my original file, without the new code
    http://"https://dl.dropbox.com/u/4380042/Udkast%20til%20dokumentation%20for%20toldpapirer%203.xlsm"


    https://dl.dropbox.com/u/4380042/Udk...pirer%203.xlsm

    Re: VBA: Worksheet_Change(ByVal Target As Range) in 2 cells + copy and paste to 2 Col


    Okay got help from another forum (thx to patel45).
    this is the code to use:

    Hi,
    I'm having a excel sheet that should search Column 'B' from cell value i put in 'G4',
    everytime i put a value in cell G4.


    Afterwards, if finding the value in Column 'B' (lets say example 'B14') it should put the cellvalue matched, in the same row, in column 'G' (example 'G14').


    I have done that by this code (i'm a noob, so bare with me) :



    This is the seeking and mark sub:



    But my main problem is, can i somehow get this to work from 2 cells.
    If any changes in G4 or I4, its should do the same search from either the cell value in G4 or if the change is in I4, it should do the search from that cell value, in Column B,
    but if the cellchange is in I4, it should return the value in Column I (example I14, if found in B14)


    Is that possible ?


    Regards
    Muggi