+ Reply to Thread
Results 1 to 3 of 3

VBA code to expand selection based on value in next cell and then merge-and-center

  1. #1
    Registered User
    Join Date
    09-06-2018
    Location
    canada
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    5

    VBA code to expand selection based on value in next cell and then merge-and-center

    Hi,

    I have a bunch of cells with either a value, eg "x" or nothing, eg "". I am having a lot of difficulty getting started on an algorithm that iterates through each row (starting in cell A1, then B1, going all the way to H1 before jumping to A2 and repeating the same thing), merging-and-center'ing based on the values in each cell.

    Here's how it would work. Start in cell A1. There is an "x" in the cell. Cell B1 is blank (" "), add it to the selection so now the selection is A1:B1. Cell C1 is also blank - add it to the selection; A1:C1. Cell D1 has an "x" in it, now take A1:C1 (excluding D1), merge-and-center, apply outside borders, and start over at D1. If it gets to H1 (the end column) without seeing another "x" (because the remaining cells are all empty) it merges-and-centers D1:H1 then proceeds to A2 and repeats the same process.

    Any ideas would be awesome. Thanks.

  2. #2
    Registered User
    Join Date
    09-06-2018
    Location
    canada
    MS-Off Ver
    Microsoft office 365 pro plus
    Posts
    5

    Re: VBA code to expand selection based on value in next cell and then merge-and-center

    This issue has been resolved - I am not sure how to delete this post.

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,460

    Re: VBA code to expand selection based on value in next cell and then merge-and-center

    Rule 08: Cross-posting Without Telling Us

    Your post does not comply with Rule 8 of our Forum RULES. Do not cross-post your question on multiple forums without telling us about your threads on other forums.

    Post a link to any other forums where you have asked the same question. If you have fewer than 10 posts here, you will not be able to post a link, but you must still tell us where else you have asked the question.

    Cross-posting is when you post the same question in other forums on the web. The last thing you want to do is waste people's time working on an issue you have already resolved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the url from the address bar in your browser) to the cross-post.

    Expect cross-posted questions without a link to be closed and a message will be posted by the moderator explaining why. We are here to help so help us to help you!

    Read this to understand why we ask you to do this, and then please edit your first post to include links to any and all cross-posts in any other forums (not just this site).

    If you have less than 10 posts, do not try to copy and paste the link. Instead, type the link out in your thread.

    No further help to be offered, please, until the OP has complied with this request.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Expand chart based on End Date selection
    By Aland2929 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-10-2017, 04:07 AM
  2. [SOLVED] VB Code to undo Merge & Center and delete rows
    By rizmomin in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-18-2017, 06:22 PM
  3. Merge and center based on adjacent cell
    By jrx in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-09-2016, 01:45 PM
  4. [SOLVED] Merge and Center Code
    By Chris Michaels in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2015, 11:43 AM
  5. Excel VBA: Merge and Center Cells Based on Date Values in Row Below
    By excelforumkeys in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-27-2014, 11:23 AM
  6. Auto expand range based on first cell selection
    By Jimmy Moggles in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-29-2011, 07:56 AM
  7. Change merge button to "center across selection"
    By Brian H in forum Excel General
    Replies: 4
    Last Post: 10-11-2005, 06:05 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