Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 5 of 5

Thread: Selecting cells and merging, with VBA

  1. #1
    Join Date
    30th August 2005
    Location
    GoldCoast, Australia
    Posts
    22

    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.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    31st January 2003
    Location
    Portsmouth, UK
    Posts
    748

    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...

    VB:
    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)

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    30th August 2005
    Location
    GoldCoast, Australia
    Posts
    22

    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...

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    31st January 2003
    Location
    Portsmouth, UK
    Posts
    748

    Re: Selecting cells and merging, with VBA

    Hi,

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

    VB:
    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

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    30th August 2005
    Location
    GoldCoast, Australia
    Posts
    22

    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

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Merging Multiple Cells
    By marmalan in forum EXCEL HELP
    Replies: 5
    Last Post: February 8th, 2007, 23:57
  2. Merging duplicate cells.
    By countryfan_nt in forum EXCEL HELP
    Replies: 5
    Last Post: January 21st, 2006, 18:42
  3. merging values in cells
    By ajcoles in forum EXCEL HELP
    Replies: 3
    Last Post: January 18th, 2006, 22:03
  4. Merging cells
    By johnnyjr20 in forum EXCEL HELP
    Replies: 7
    Last Post: October 14th, 2005, 07:42
  5. Merging Data In Cells
    By hlcecil in forum Excel and/or Access Help
    Replies: 4
    Last Post: August 31st, 2004, 23:32

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
  •  
porno