[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Merge cells in range

Posted on 2012-04-01
2
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
YDs60 earned 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

649 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