Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 410
Default Merge Macro

On Jan 11, 9:28*am, "Bernie Deitrick" <deitbe @ consumer dot org
wrote:
This will do one row (row 2 for this sample - you need to loop on row1, but wasn't sure where you
set that value), and I wasn't sure what you wanted in the cells after merging, so I just put a
label....

Sub TryNow()
Dim Row1 As Long
Dim myC As Range
Dim myR As Range
Dim myM As Range
Dim I As Integer
Dim W As Integer

Row1 = 2
'Start your loop here instead of setting Row1 with
'For Row1 = 2 to Whatever.....

Set myM = Range("Z" & Row1)

W = 1

Set myR = Range("P" & Row1).Resize(1, 5)
For Each myC In myR
* *I = myC.Value
* *If I 0 Then
* * * With myM.Offset(0, W).Resize(1, myC.Value)
* * * * *.Merge
* * * * *.Value = "Merged"
* * * End With
* * * W = W + I
* *End If
Next myC

'End your loop here with * *Next Row1

End Sub

--
HTH,
Bernie
MS Excel MVP

"jlclyde" wrote in message

...



Sub Macro6()
Dim row1 As Long
Dim col1 As Long


* * * * *Set MYrange = Application.InputBox(Prompt:="Please select
range", _
* *Title:="Tihs Siht Kcuf", Type:=8)
* *row1 = MYrange.Row
* *col1 = MYrange.Column


* * * * * *Range(MYrange, Cells(row1, col1 - 1 + Range("P" &
row1))).Select
* * * * * *Selection.Merge
* * * * * *Selection = Range("P" & row1) & "%"
* * * * * *Selection.Interior.ColorIndex = 35


I have been working on this all night and this is the best I can come
up with. *I need to merge cells based on what is in P, Q, R, S, and T


So for instance IF Range("P" row1) *<0 then
* * * * * * * * * * *Starting at Range("AA" row1) I want the cells to
merge for the number that is in "P". *So if the number is 10 then it
woudl merge cells AA:AJ. *Then merge the cells to the right based on
what is in Q. *The tricky part is that any of these at anytime can be
0 and I can not think of how to do this.


Thanks,
Jay


Here is all of my code.


* * * * * * * *Set myrange2 = Cells(row1, col1 + Range("P" & row1))
* * * * * * * *Range(myrange2, Cells(row1, col1 - 1 + Range("Q" &
row1) + Range("P" & row1))).Select
* * * * * * * *Selection.Merge
* * * * * * * *Selection = Range("Q" & row1) & "%"


* *Range(Cells(row1, col1 + Range("p" & row1) + Range("Q" & row1)),
Cells(row1, _
* *col1 + Range("P" & row1) + Range("Q" & row1) + Range("R" &
row1))).Select
* *Selection.Merge
* *Selection = Range("R" & row1) & "%"
* *Selection.Interior.ColorIndex = 36


* *Range(Cells(row1, col1 + Range("p" & row1) + Range("Q" & row1) + _
* *Range("R" & row1) + 1), Cells(row1, col1 + Range("P" & row1) + _
* *Range("Q" & row1) + Range("R" & row1) + Range("S" & row1) -
1)).Select


* *Selection.Merge
* *Selection = Range("S" & row1) & "%"
* *Selection.Interior.ColorIndex = 34- Hide quoted text -


- Show quoted text -


This does exactly what I want. I will add the titles and fill colrs.
thank you very much for this.
Jay


 
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
How to merge / combine several worksheets into one new worksheet without VBA / Macro? FOR EXPERTS [email protected] Excel Worksheet Functions 9 August 13th 07 04:19 AM
Merge cells with formula or macro? Joe M. Excel Discussion (Misc queries) 5 July 23rd 07 10:28 PM
merge columns into single report - macro needed aquaflow Excel Discussion (Misc queries) 2 February 5th 07 12:41 PM
Macro to merge open workbooks Barry McConnell Excel Discussion (Misc queries) 1 August 23rd 06 05:09 PM
Mail Merge macro Wonder Women Excel Discussion (Misc queries) 4 January 5th 06 07:37 PM


All times are GMT +1. The time now is 12:59 PM.

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

About Us

"It's about Microsoft Excel"