Announcement

Collapse
No announcement yet.

Unconfigured Ad Widget

Collapse

Selecting cells and merging, with VBA

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Selecting cells and merging, with VBA

    I am trying to make a Macro that will select the next cell down, then the next cell across. and then merge the two. I am a novice at VBA, and cannot crack this simple task. Thanks.

  • #2
    Re: Selecting cells and merging, with VBA

    Hi,

    I think this is what you are after - this will merge the cell you are in and the one below and too the left...

    Code:
    Sub mergeIt()
    
    Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(1, 1)).Merge
    ActiveCell.Select
    
    End Sub
    this wil create a merged cell 2x2 with the active cell as the top left hand corner...if you want to change the size of the new mereged cell then play with the offsets (the first on determines which cell is the top left of the new merged cells and the second how large the newly merged cell will be)


    D ;o)
    D

    Better a bad day on the water than a good day in the office

    Comment


    • #3
      Re: Selecting cells and merging, with VBA

      Thanks for your reply - As you suggested, I played around with the offsets, and got the required cells to merge, which was actually the cell down one and THEN the cell across one. Now I need to make the the newly merged cell the active one. Can you help with this too? I feel like an extreme novice - my questions pale beside all the other posts! But thanks a million. If you are ever on the Gold Coast...

      Comment


      • #4
        Re: Selecting cells and merging, with VBA

        Hi,

        I've think this should sort it out for you...

        Code:
            ActiveCell.Offset(1, 0).Select
            Range(ActiveCell.Offset(0, 0), ActiveCell.Offset(0, 1)).Merge
            ActiveCell.Select
        if this does not work, can you post the code you now have and I'll have a play with that for you...

        D
        D

        Better a bad day on the water than a good day in the office

        Comment


        • #5
          Re: Selecting cells and merging, with VBA

          Dave: Thanks for the help. Its works, and I've learned something. Not to mention the inspiration to keep learning. // Dejayajay

          Comment

          Trending

          Collapse

          There are no results that meet this criteria.

          Working...
          X