Consulting

Results 1 to 4 of 4

Thread: Reg : Merging of cells

  1. #1

    Post Reg : Merging of cells

    Hi,
    I am a newbie in excel programming n need a solution for one of the problem.

    Please refer the attachment and help me out with your solutions.


    I need to merger the cells from Column F-J based on the no. of validations that a particular filetype(Column C) has.
    Eg: doc has validation1-validation 5.So merger them.
    Similarly xls has validation1-Validation3.So merge them
    and so on.

    Kindly help me in figuring out how this can be done at the earliest.

    regards
    Vidya

  2. #2
    Moderator VBAX Guru Simon Lloyd's Avatar
    Joined
    Sep 2005
    Location
    UK
    Posts
    3,003
    Location
    Firstly you can upload a workbook, adding a worksheet to a word document is pointless.

    Secondly why merge the cells?, they will cause you so much problems in the future, you would be better of Centering text across a range of cells.
    Regards,
    Simon
    Please read this before cross posting!
    In the unlikely event you didn't get your answer here try Microsoft Office Discussion @ The Code Cage
    If I have seen further it is by standing on the shoulders of giants.
    Isaac Newton, Letter to Robert Hooke, February 5, 1675 English mathematician & physicist (1642 - 1727)

  3. #3
    Hi Simon,
    Thanks for the suggestion. But am developing a small application for the learning purpose. I would like to know about the merging.

    Attached is the spreadsheet for your reference.
    Would be of great help if u could guide m thru it.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,443
    Location
    [vba]

    Public Sub ProcessData()
    Const TEST_COLUMN As String = "A" '<<<< change to suit
    Dim Lastrow As Long
    Dim LastCol As Long
    Dim i As Long

    Application.ScreenUpdating = False

    With ActiveSheet

    Lastrow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
    For i = 2 To Lastrow

    If .Cells(i, "B").Value2 <> "" Then

    LastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column
    Do

    i = i + 1
    If .Cells(i, "B").Value2 = "" Then .Cells(i, "F").Resize(, LastCol - 5).Merge
    Loop Until .Cells(i, TEST_COLUMN).Value2 = "" Or i > Lastrow
    i = i - 1
    End If
    Next i
    End With

    Application.ScreenUpdating = True
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

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