Solved

Merge cells in range

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
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 …

706 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

19 Experts available now in Live!

Get 1:1 Help Now