Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for merging cells


Hi,

I have a application that can export to XL.
This application also have the possibility to execute a XL macro after
the exporting is done. Using this "execute macro" function I would like
to merge cells that have the same data as the next row in the same
column and this should only be done in the 3 first columns. See the
attached bmp file for how it looks and should look.

I have searched the forum for examples without luck so I must turn to
you excel/macro wizards out there since I'm no programmer .

Thx in advance


+-------------------------------------------------------------------+
|Filename: Excelmacro.bmp |
|Download: http://www.excelforum.com/attachment.php?postid=4439 |
+-------------------------------------------------------------------+

--
XLuser
------------------------------------------------------------------------
XLuser's Profile: http://www.excelforum.com/member.php...o&userid=32347
View this thread: http://www.excelforum.com/showthread...hreadid=521094

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro for merging cells


Problem solved

I found an example published by Frank Kabel in Maj 2004 and with the
help of others here at the company we modified it some and came up with
this:


Code:
--------------------
Sub mergebycol()
Dim lastrow As Long
Dim row_index As Long
Dim col_index As Long
Dim start_index As Long
Dim wks As Worksheet
Set wks = ActiveSheet
With wks
For col_index = 1 To 3
lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
start_index = 1
For row_index = 2 To lastrow + 1
If .Cells(row_index, col_index).Value < .Cells(row_index - 1, col_index).Value Then
If row_index - start_index 1 Then
Application.DisplayAlerts = False
With Range(.Cells(start_index, col_index), .Cells(row_index - 1, col_index))
.Merge
.VerticalAlignment = xlCenter
End With
Application.DisplayAlerts = True
End If
start_index = row_index
End If
Next
Next
End With
End Sub
--------------------


--
XLuser
------------------------------------------------------------------------
XLuser's Profile: http://www.excelforum.com/member.php...o&userid=32347
View this thread: http://www.excelforum.com/showthread...hreadid=521094

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
merging cells and eliminating spaces for empty cells Jill Excel Discussion (Misc queries) 2 April 2nd 10 07:43 PM
Merging Macro FARAZ QURESHI Excel Discussion (Misc queries) 3 May 9th 09 01:52 PM
Formula for merging cells/re sizing cells Mathicas Excel Discussion (Misc queries) 1 September 29th 08 08:16 PM
merging cells together but keeping all data from the cells Pete C[_2_] Excel Discussion (Misc queries) 3 May 16th 08 10:14 PM
merging cells/data using a Macro crimsonkng Excel Programming 2 June 10th 05 07:34 PM


All times are GMT +1. The time now is 07:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"