Solved

Merge cells in range

Posted on 2012-04-01
2
191 Views
Last Modified: 2012-04-01
Hello Experts,

I thought I knew what I was doing - but NO.  I am trying to merge cells quickly.
On my sheet I have Range("K7:BA7") that I need to merge. (K7&L7, then M7&N7 etc.)

Here is my code:

   Dim i As Long

   For i = 11 To 45 Step 2
   Sheet7.range(cells(7, i), cells(7, i + 1)).merge
   Next i

However I am getting an error code 1004 - I do not know what I am doing wrong.

Can you please correct me which will educate me, as well.

Thank you!
0
Comment
Question by:mike637
2 Comments
 
LVL 1

Accepted Solution

by:
YDs60 earned 500 total points
ID: 37793244
mike637, I tried your code on a pretty clean Excel 2003 SP3 workbook and it works perfectly.  No 1004 error seen.
0
 

Author Closing Comment

by:mike637
ID: 37793248
You are right - thanks for checking, so the points are yours.  I was being stupid and did not have it in a module but was trying to initiate from another worksheet routine.

I will remember next time.  I knew this, I just forgot.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now