+ Reply to Thread
Results 1 to 2 of 2

VBA to merge cells automatically when text is typed into cell.

  1. #1
    Registered User
    Join Date
    10-10-2019
    Location
    Sunshine Coast
    MS-Off Ver
    2010
    Posts
    13

    VBA to merge cells automatically when text is typed into cell.

    Managed to get a solution. Solved

    I am trying to as you type into certain cells it merges with the next cell next to it.
    Therefore If E1 contains Kayaking or SUP or Canoeing or (keep going etc for a several more) it merges E1 to E2.
    These ranges would be in several rows down in several columns.
    If specific text found in a row in column E, merge with column F
    If specific text found in a row in column I, merge with column J
    If specific text found in row in column M, merge with column N etc

    I have written a macro that does this, however would like to do it when you type into a cell so it shows. I know merging cells keeps the left most information, the cell to right would be blank anyway.
    I found an old post, cannot remember where now that had a similar problem, but this merges only when you click left and not enter is pressed and I am struggling to adapt it. The code is below.
    For Each rw In Selection.Rows
    If Cells(rw.Row, 1) = 5 Then 'column A of each row
    Range(Cells(rw.Row, 3), Cells(rw.Row, 6)).Merge
    End If
    Next rw
    End Sub
    Attached Files Attached Files
    Last edited by Matthew2; 09-24-2021 at 12:18 AM.

  2. #2
    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
    81,284

    Re: VBA to merge cells automatically when text is typed into cell.

    Administrative Note:

    Please share the solution you found for the benefit of all.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    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] Automatically Merge Cells if has the same cell value
    By dedark05 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 02-10-2020, 04:15 AM
  2. [SOLVED] Repeat text typed in one cell automatically in another cell
    By SueS in forum Excel General
    Replies: 3
    Last Post: 07-21-2014, 10:59 PM
  3. Can Macros be set to automatically run when something is pasted or typed into a cell?
    By Lylestyle89 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-25-2013, 09:06 PM
  4. Replies: 5
    Last Post: 02-23-2007, 12:11 PM
  5. Can numbers be typed to automatically be negative in cells?
    By finnplan in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-08-2005, 06:30 PM
  6. [SOLVED] Excel merged cell - can it automatically expand as text is typed?
    By Joanne (JAS) in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 01-07-2005, 09:06 PM
  7. [SOLVED] Excel merged cell - can it automatically expand as text is typed?
    By Joanne (JAS) in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 01-07-2005, 07:06 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