+ Reply to Thread
Results 1 to 2 of 2

Issue selecting and merging cells after a row insert

  1. #1
    Registered User
    Join Date
    02-19-2014
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    1

    Issue selecting and merging cells after a row insert

    I have a monthly calendar in excel, I can store 5 entries, when it comes to the 6th, I need to insert a complete row (which I can do)
    However, the new row has 2 cells, I am struggling how to the select both cells in the new row below and merge them before entering text into the merged cell

    I am basically finding the date cell which has a blank cell to the right, then using that cell to enter text in the merged cell (of which there are 5) below. I am then inserting a complete row below that but it has the 2 cells in the new row instead of being merged

    For taskDateLooper = taskStartDate To taskEndDate

    xlBook.Sheets(Format(taskDateLooper, "MMM yyyy")).Activate
    Set xlSheet = xlBook.Sheets(Format(taskDateLooper, "MMM yyyy"))
    'MsgBox (taskDateLooper)
    strSearch = Format(taskDateLooper, "Short Date")
    Set aCell = xlSheet.Range("A1:P36").Find(What:=strSearch)

    aCell.Activate
    ' This basically adds text to the same cell with text on a new line
    ' Really this needs to add anotehr row in and then copy the task to
    ' the next cell down - THINK ABOUT HOW TO TRACK THIS OUT
    ' WE HAVE 5 CELLS AVAILABLE, REALLY ONLY NEED TO ADD ANOTHER ROW IF
    ' GO BEYOND 5 CELLS

    If cellCounter > 5 Then

    ' MORE THAN 5 TASKS IN FOR THAT DATE, NEED TO ADD IN NEW ROW in table
    aCell.Offset(cellCounter).EntireRow.Insert
    ' IN THE CALENDAR WE NEED TO MERGE WITH THE CELL TO THE RIGHT TO ENSURE THIS
    ' WORKS AND DOES NOT CAUSE TEXT TO DISAPPER IN THE CELL TO THE RIGHT
    '???? THIS IS WHERE I AM STRUGGLING TO SELECT THE NEW CELLS BELOW AND MERGING THEM
    '???? BEFORE THEN ENTERING THE TEXT

    End If

    If xlSheet.Cells(aCell.Row + cellCounter, aCell.Column).Value <> " " Then
    xlSheet.Cells(aCell.Row + cellCounter, aCell.Column).Value = t.Name
    Else
    xlSheet.Cells(aCell.Row + cellCounter, aCell.Column).Value = t.Name
    End If

    cellCounter = cellCounter + 1

    Next taskDateLooper

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    6,301

    Re: Issue selecting and merging cells after a row insert

    After
    Please Login or Register  to view this content.
    use this line
    Please Login or Register  to view this content.

+ 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. Replies: 1
    Last Post: 07-06-2013, 10:13 AM
  2. Replies: 1
    Last Post: 11-08-2012, 12:15 PM
  3. [SOLVED] Dynamic Copy + Insert copied cells to a new row Macro by selecting two fields
    By engrogg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-10-2012, 07:25 AM
  4. dynamically linked cells--merging issue
    By Anthony_Schultz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-04-2011, 04:56 PM
  5. Replies: 3
    Last Post: 01-25-2011, 09:31 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