+ Reply to Thread
Results 1 to 3 of 3

Inserting data in the next empty row that contains horizontally merged cells

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    55

    Inserting data in the next empty row that contains horizontally merged cells

    Hello everybody,

    I have a work sheet (sheet1)with two merged columns, first column is "H" (merged range "H" to "T") and second column is "U" (merged range "U" to "AG") with no merged rows. I tried to insert data from a user form with two combo boxes (cmb1 & cmb2) in the NEXT empty row within the range of ("H16:H20"). I tried this code but it has three problems (1) it starts inserting at row ("H17"), (2)no range limits, it keeps inserting data below (H"20") and (3) no data is inserted in the second column ("U") at all. If some body can help me, I will appreciate that.
    HTML Code: 
    Private Sub CommandButton1_Click()
    Dim ws As Worksheet
    Set ws = Worksheets("sheet1")
    
    RowCount = ws.Range("H16:H20").CurrentRegion.Rows.Count
        With ws.Range("H16")
         .Offset(RowCount, 0) = Me.cmb1.Value
         .Offset(RowCount, 1) = Me.cmb2.Value
        End With
    End Sub
    Thank you so much

    Stay safe

    Karim

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,679

    Re: Inserting data in the next empty row that contains horizontally merged cells

    There's only 1 correct answer, Loose the merged columns.

    Merged cells and VBA don't go together well (or even not at all).

    This is one of Microsoft's worst inventions ever.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Registered User
    Join Date
    03-19-2013
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2010
    Posts
    55

    Re: Inserting data in the next empty row that contains horizontally merged cells

    Dear bakerman2,

    Thank you so much for your reply

    Take care

    Karim

+ 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: 5
    Last Post: 04-02-2020, 09:33 AM
  2. Replies: 1
    Last Post: 07-20-2015, 02:27 PM
  3. Data sort, empty formula cells to bottom merged cells!
    By ikkuh in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-09-2013, 03:10 AM
  4. Inserting Rows Merged Cells
    By ClubCrackerz in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-14-2012, 04:07 PM
  5. Can I sort horizontally some how when I have merged cells?
    By jasonmcbride in forum Excel General
    Replies: 6
    Last Post: 04-20-2012, 01:57 PM
  6. Inserting Rows that contain merged cells
    By maverick22 in forum Excel General
    Replies: 1
    Last Post: 08-15-2007, 04:22 PM
  7. Inserting data horizontally
    By toddroutt in forum Excel General
    Replies: 4
    Last Post: 08-10-2007, 07:25 AM

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