Results 1 to 6 of 6

merge cells using vba

Threaded View

  1. #1
    Registered User
    Join Date
    09-25-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    88

    merge cells using vba

    Hi excel guru,

    I want to merge cells using vba.The below code working fine for product more than one but when there is only one product then below macro is not working.

    Please find the attached sample file.

    Please help me to solve this issue.

    Regards

    Upa


    Sub Merge()
    Dim lastRow As Long
        
        lastRow = ActiveSheet.Range("B" & Rows.Count).End(xlUp).Select
        ActiveCell.Offset(0, 1).Select
        Range(Selection, Selection.End(xlUp)).Select
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlBottom
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
            End With
            Selection.Merge
            With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = True
        End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Macro merge cells separated by comma, ignore blank cells
    By lagiosman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-22-2014, 04:49 PM
  2. Replies: 2
    Last Post: 01-22-2014, 02:35 PM
  3. Merge data from cells on 2nd columns in which the cells of 1st column repeat
    By jagke in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 01-14-2013, 01:06 PM
  4. Replies: 0
    Last Post: 11-03-2012, 06:11 PM
  5. Replies: 0
    Last Post: 06-27-2012, 06:29 AM
  6. How to merge date from adjacent cells inbetween current cells
    By hdawson in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2009, 08:03 PM
  7. Replies: 2
    Last Post: 07-20-2006, 09:05 AM
  8. [SOLVED] MERGE CELLSHow to merge two cells in excel?
    By laure abbass in forum Excel General
    Replies: 1
    Last Post: 11-10-2005, 01:50 PM

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