+ Reply to Thread
Results 1 to 4 of 4

update button code

Hybrid View

  1. #1
    Registered User
    Join Date
    08-29-2012
    Location
    Amman
    MS-Off Ver
    Excel 2007
    Posts
    36

    update button code

    hi ..
    I am working on two sheets .. Al sheet and template sheet ..
    I want to add an update button to check if all items in column B Al sheet exists in column B template sheet
    if an item not exists then I want to add it to the end of column B template sheet ..
    so I need ur help to write the code doing that ..

    hope that I explain it well !

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: update button code

    This should work, but if it does not, you need to attach your sample sheets.
    Sub find_copy2()
    Dim c2 As Range, c As Range
    With Sheets("Al sheet")
    LR = .Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
     For Each c In .Range("B1:B" & LR)
       Set c2 = Sheets("template sheet").Columns(2).Find(c, , xlValues, xlWhole)
        If c2 Is Nothing Then
        c.EntireRow.Copy Sheets("template sheet").Cells(Rows.Count, 1).End(xlUp).Offset(1)
        End If
       Next
     End With
    End Sub

  3. #3
    Registered User
    Join Date
    08-29-2012
    Location
    Amman
    MS-Off Ver
    Excel 2007
    Posts
    36

    Re: update button code

    thanks a lot .. it is working
    but I have some empty cells between rows in "Al sheet"
    how can I skip those from adding to "template sheet" ???

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: update button code

    Hmm!
    It could be for two reasons.
    1.The code is not working
    2. You must also have blank cells in the other sheet.
    I have tested it again by inserting blank rows on "Al sheet". The code has not copied the blanks as there are not blank cells to match, or find in template sheet

+ 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