Wrox Programmer Forums
|
BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2
This is the forum to discuss the Wrox book Excel 2007 VBA Programmer's Reference by John Green, Stephen Bullen, Rob Bovey, Michael Alexander; ISBN: 9780470046432
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Excel 2007 VBA Programmer's Reference ISBN: 978-0-470-04643-2 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 31st, 2009, 01:21 PM
Authorized User
 
Join Date: Sep 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default merging cells

Morning all.
Let's see.... I've modified an existing macro to test for borders, and to merge the selected cells.
My If test appears to work ok, but my core operation doesn't.
My code is:

Code:
 
For Each rcell2 In Selection
      If rcell2.Borders(xlEdgeBottom).LineStyle = xlSolid Then
               ActiveSheet.Range(rcell1, rcell2).Select
               With Selection
                       .Merge
                       .VerticalAlignment = xlCenter
                       .HorizontalAlignment = xlCenter
               End With
               'Set rcell1 = Nothing
               'Set rcell2 = Nothing
               ActiveCell.Offset(1, 0).Select
      'end if
      End If
Next rcell2
I have 3 if tests outside of the above. My intention was to iterate through a series of rows, looking for a border on top, and a border on the bottom, after an undefined number of rows.

Once it finds the rows, I want to select them, and merge them.
However, in the case of my present macro, it merges, iterates through a second set of rows, and selects the first set, and then selects, and merges the second set with the first set.
This does not work.
My thinking at this point is that the rcell1 variable has the first row's location still stored in its buffer, and if this indeed the case, I need the rcell1 buffer emptied, to start with a new row location.
The problem is-- I'm not clear on how this is done. Anyone know how to do this?
Thank you.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting Cells In Flexgrid and Merging rfstuck Pro VB 6 0 April 10th, 2008 10:17 AM
Datagrid-Merging Cells p330418 ASP.NET 2.0 Professional 0 February 29th, 2008 12:06 AM
Merging cells in Datagrid p330418 ASP.NET 2.0 Basics 0 February 28th, 2008 11:21 PM
merging excel cells anoopkpanicker Beginning VB 6 1 March 26th, 2007 05:11 PM
How to know cells in table is merging?? DorisTan VB How-To 0 January 13th, 2005 09:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.