+ Reply to Thread
Results 1 to 3 of 3

Excel VBA search cell value and select action if the value exist or not

  1. #1
    Registered User
    Join Date
    01-11-2014
    Location
    Paris,france
    MS-Off Ver
    Excel 2010
    Posts
    2

    Excel VBA search cell value and select action if the value exist or not

    Hy, I made 2 tabs : "Affaires" and "Actions" .

    For "Affaires" it's OK: I have my input info Form and my Search and VisualizeFom

    Bu for Actions I have a problem: Actually my form allow me to insert data but it's creating a new line each time.
    I want the program to check in the "Actions" Tab if the Affaire number (which is in a COmbobox of my Action Form) already exists.
    If yes: insert the data of the input form onte same line
    If not: create a new line and insert data

    I join my folder to be more clear, please excuse my vba code, I am a beginner

    Thanks for your help

    Nanouna Test VBA.xlsm

  2. #2
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: Excel VBA search cell value and select action if the value exist or not


    Hi,

    see the help of the Find method for example …

  3. #3
    Registered User
    Join Date
    01-11-2014
    Location
    Paris,france
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Excel VBA search cell value and select action if the value exist or not

    Bonsoir,

    Merci pour le tips j'ai trouvé une solution:

    With Sheets("Actions")

    Set columnAffaire = .Columns(1)
    Set c = columnAffaire.Find(ComboBox65.Value, LookIn:=xlValues)

    If MsgBox("Enregistrer l'action en cours?", vbOK, "Créer Action") = vbOK Then




    If c Is Nothing Then

    Der_lig = .Range("D65000").End(xlUp).Row + 1
    .Range("A" & Der_lig) = ComboBox65
    .Range("B" & Der_lig) = ComboBox1
    .Range("C" & Der_lig) = ComboBox2
    .Range("D" & Der_lig) = ComboBox3
    .Range("E" & Der_lig) = TextBox4
    .Range("F" & Der_lig) = TextBox3
    .Range("G" & Der_lig) = ComboBox4
    .Range("H" & Der_lig) = TextBox2
    .Range("I" & Der_lig) = 1
    .Range("J" & Der_lig) = TextBox46
    .Range("JA" & Der_lig) = ComboBox66

    Else
    adresscell = c.Address
    Range(adresscell).Activate

    lineNb = c.Row
    Do While Not (IsEmpty(ActiveCell))
    NbColumn = NbColumn + 1
    Selection.Offset(0, 1).Select

    Loop

    colNb = ActiveCell.Column
    'lineNb = ActiveCell.Line

    .Cells(lineNb, colNb) = ComboBox65
    .Cells(lineNb, colNb + 1) = ComboBox1
    .Cells(lineNb, colNb + 2) = ComboBox2
    .Cells(lineNb, colNb + 3) = ComboBox3
    .Cells(lineNb, colNb + 4) = TextBox4
    .Cells(lineNb, colNb + 5) = TextBox3
    .Cells(lineNb, colNb + 6) = ComboBox4
    .Cells(lineNb, colNb + 7) = TextBox2
    .Cells(lineNb, colNb + 8) = WorksheetFunction.Floor(colNb / 8, 1) + 1
    .Cells(lineNb, colNb + 7) = TextBox46
    .Cells(lineNb, "JA") = ComboBox66
    End If



    End If



    End With
    End If
    ActiveWorkbook.Save
    Unload Me


    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Select Multiple workbooks at once to perform an action
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2013, 06:09 AM
  2. Select Multiple workbooks at once to perform an action
    By rshnkmr39 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-03-2013, 05:23 AM
  3. Search for a word and select next cell
    By Fishhooky in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-22-2009, 07:17 AM
  4. Macro to select the result of an autofilter action
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-22-2005, 07:15 AM
  5. Search for Value Exist
    By jbortfeld in forum Excel General
    Replies: 1
    Last Post: 02-26-2005, 10:18 AM

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