Solved

Merge cells in range

Posted on 2012-04-01
2
196 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 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

732 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