+ Reply to Thread
Results 1 to 2 of 2

VBA for merging columns with i counter for rows

  1. #1
    Registered User
    Join Date
    01-09-2018
    Location
    Kansas
    MS-Off Ver
    10
    Posts
    1

    VBA for merging columns with i counter for rows

    Hi,

    I need to merge certain columns like A2:G2 and merging should continue until A15:G15. Currently I have written a syntax Range(A2:G2).Merge which works perfect. to make it with the "I" loop for example
    for I=0 to 14
    Range(A2+i:G2+i).Merge
    I=I+1
    Next I

    it doesn't work and gives me an error. I tried different syntax range(""A""& 2+i:""G""&2+i).Merge and this also gives me error. Could anyone help me to fix this.

    Thanks,

  2. #2
    Forum Contributor
    Join Date
    06-12-2017
    Location
    USA
    MS-Off Ver
    2010
    Posts
    167

    Re: VBA for merging columns with i counter for rows

    Try

    Please Login or Register  to view this content.
    The I automatically will count up so no need for that

    You could also do a Range(Cells(2+i,1),cells(2+i,7)).merge
    This uses Range(cell(row index, column index),cell(row index, column index)) which is just a numerical count for columns and rows like a grid. I find it easier with looping.

+ 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. Merging rows into columns....
    By Marckk in forum Excel General
    Replies: 5
    Last Post: 10-17-2014, 11:41 AM
  2. [SOLVED] Merging Columns and Rows of Data into a Matrix
    By DaveBre in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-04-2014, 06:21 AM
  3. Merging entries in columns to form new rows
    By KristaLane in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-02-2014, 11:57 AM
  4. [SOLVED] Merging rows and moving data to columns
    By ranmyaku in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-03-2013, 01:48 PM
  5. Merging Rows & Columns on Unique Identifier
    By oxv in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-20-2012, 06:52 PM
  6. Help merging similar rows into columns
    By MR UZZI in forum Excel General
    Replies: 4
    Last Post: 11-26-2012, 12:16 AM
  7. How do I merge entire columns without merging the rows?
    By Dean_Bradko in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-22-2005, 03: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