Consulting

Results 1 to 5 of 5

Thread: Merging cells and suppress excel's popup

  1. #1

    Merging cells and suppress excel's popup

    Hi all,
    I have a workbook that pulls out data from a master list.
    from column A onwards, it pulls out the item's name("A"), Date of Production("B") and total quantity("C").
    For an item with different production dates, the total quantity are the same. So, I first sort out items according to their names, and merge the total quantities together to 1 cell. ( for example"A1" to "A5" are of the same item apple, and "A6" to "A11" are all bananas) So I need to merge the cells of total quantities from C1 to C5 and B6 to B11 respectively.

    2 problems cropped out: 1) I used record macro, but it cannot dynamically merge the cells if the number of items change.
    [vba]
    Range("C1:C5").Select
    Selection.Merge
    Range("C6:C11").Select
    Selection.Merge
    [/vba]

    2) When I run the macro, a msgbox keeps popping out:
    "selection contains multiple data values. merging cells will keep the left uppermost data only."

    so i tried using [vba]on error resume next[/vba] , but it still does not suppress the popup.

    Please help!

  2. #2
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Without testing - try Application.DisplayAlerts = False before the merge (don't forget to put it back to True afterwards)
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  3. #3
    Quote Originally Posted by johnske
    Without testing - try Application.DisplayAlerts = False
    before the merge (don't forget to put it back to True afterwards)
    ok thanks! but i still cannot figure out how to merge the quantities together for the same items... is it not possible?

  4. #4
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post a sample showing the outcome that you are after?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    [VBA]
    iItem = Cells(irow, StkCodeProdnFC)
    For iirow = iirow To llrow
    jItem = Cells(iirow, StkCodeProdnFC)
    If jItem = iItem Then
    jrow = jrow + 1
    End If

    Next iirow
    Sheets("by materials").Activate
    Range(Cells(irow, StkDescProdnFC), Cells(jrow, StkDescProdnFC)).Merge
    Range(Cells(irow, ETAProdnFC), Cells(jrow, ETAProdnFC)).Merge
    Range(Cells(irow, TWIPDrawnProdnFC), Cells(jrow, TWIPDrawnProdnFC)).Merge
    Range(Cells(irow, AwaitingDeliveryProdnFC), Cells(jrow, AwaitingDeliveryProdnFC)).Merge
    Range(Cells(irow, PendingFinInstrnProdnFC), Cells(jrow, PendingFinInstrnProdnFC)).Merge
    Range(Cells(irow, ShrtPrcheProdnFC), Cells(jrow, ShrtPrcheProdnFC)).Merge
    Range(Cells(irow, PhyStkQtyProdnFC), Cells(jrow, PhyStkQtyProdnFC)).Merge
    Range(Cells(irow, StkCodeProdnFC), Cells(jrow, StkCodeProdnFC)).Merge

    [/VBA]
    i figured it out to b something like this...thanks anyway!

Posting Permissions

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