Results 1 to 3 of 3
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The range C1:BB1 is filled with value. (not all cells are filled with value)

    example in C1 have QQ, in D1 have ZZ... ecc

    now with vba....

    for test use my_var="AA"

    i want to loop in the range and if the value of my_var existis exit sub but if AA not existis in range add AA in the last free cell of range exit sub

    in this case the value AA go in E1

  2. #2
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    Try

    [codebox]Sub CheckSelection()
    Dim c
    For Each c In Worksheets("MATRICOLE (2)").Range("C1:BB1").Cells
    If c.Value = "AA" Then
    MsgBox "Found"
    Exit Sub
    Else

    If c.Value = "" Then
    c.Value = "AA"
    Exit Sub
    End If

    End If
    Next c

    End Sub[/codebox]
    Jerry

  3. #3
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='jezza' post='792109' date='04-Sep-2009 14:33']Try

    [codebox]Sub CheckSelection()
    Dim c
    For Each c In Worksheets("MATRICOLE (2)").Range("C1:BB1").Cells
    If c.Value = "AA" Then
    MsgBox "Found"
    Exit Sub
    Else

    If c.Value = "" Then
    c.Value = "AA"
    Exit Sub
    End If

    End If
    Next c

    End Sub[/codebox][/quote]

    WORK PERFECT!

Posting Permissions

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