Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to merge / combine several worksheets into one new worksheet without VBA / Macro? FOR EXPERTS | Excel Worksheet Functions | |||
Merge cells with formula or macro? | Excel Discussion (Misc queries) | |||
merge columns into single report - macro needed | Excel Discussion (Misc queries) | |||
Macro to merge open workbooks | Excel Discussion (Misc queries) | |||
Mail Merge macro | Excel Discussion (Misc queries) |