Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Selection issue
Morning all.
I'm making a user form, and want to select a cell to place my equation, then with that selection choice, offset upwards, and to the side, to select and merge two sets of two cells, each. I understand with my selection that I'd use the following: activecell.offset(0,1).select to get my first cell selection. But how do I retain that initial selection, and then offset one more up, to then merge those two cells? Thank you. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Selection issue
I'm not 100% sure what you are wanting but I think you want to merge the cell
to the right of the activecell with the cell one row above that cell, right? If so, you can use this line of code. Union(ActiveCell.Offset(0, 1), ActiveCell.Offset(-1, 1)).MergeCells = True Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "Steve" wrote: Morning all. I'm making a user form, and want to select a cell to place my equation, then with that selection choice, offset upwards, and to the side, to select and merge two sets of two cells, each. I understand with my selection that I'd use the following: activecell.offset(0,1).select to get my first cell selection. But how do I retain that initial selection, and then offset one more up, to then merge those two cells? Thank you. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Selection issue
Hi Ryan,
Sorry that it wasn't clear enough. I want to select one cell, and then merge the one above, with that cell-- merging two cells in the same column, together. I then want to offset one column to the right, and merge two cells together. My issue is how do I <select the two cells in the single column to merge them? Thank you. "Ryan H" wrote: I'm not 100% sure what you are wanting but I think you want to merge the cell to the right of the activecell with the cell one row above that cell, right? If so, you can use this line of code. Union(ActiveCell.Offset(0, 1), ActiveCell.Offset(-1, 1)).MergeCells = True Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "Steve" wrote: Morning all. I'm making a user form, and want to select a cell to place my equation, then with that selection choice, offset upwards, and to the side, to select and merge two sets of two cells, each. I understand with my selection that I'd use the following: activecell.offset(0,1).select to get my first cell selection. But how do I retain that initial selection, and then offset one more up, to then merge those two cells? Thank you. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Selection issue
Steve;603938 Wrote: Morning all. I'm making a user form, and want to select a cell to place my equation, then with that selection choice, offset upwards, and to the side, to select and merge two sets of two cells, each. I understand with my selection that I'd use the following: activecell.offset(0,1).select to get my first cell selection. But how do I retain that initial selection, and then offset one more up, to then merge those two cells? Thank you. Set StartCell = Range("D4") StartCell.offset(0,1).formula = "=Sum(A1:A5)" StartCell.offset(0,1).resize(1,2).merge -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=167483 Microsoft Office Help |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Cell Selection issue
In order to select merged cells you have to reference the entire range
address. For example: To select a single cell you would use Range("A1").Select If A1 and A2 were merged you use Range("A1:A2").Select Here are a few lines of code you can use: ' merge the active cell and cell above active cell Union(ActiveCell, ActiveCell.Offset(-1, 0)).MergeCells = True ' merge the cell right of active cell and cell above that cell Union(ActiveCell.Offset(0, 1), ActiveCell.Offset(-1, 1)).MergeCells = True ' select merged cells to the right of active cell Range(Cells(ActiveCell.Row, ActiveCell.Column + 1), Cells(ActiveCell.Row - 1, ActiveCell.Column + 1)).Select Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "Steve" wrote: Hi Ryan, Sorry that it wasn't clear enough. I want to select one cell, and then merge the one above, with that cell-- merging two cells in the same column, together. I then want to offset one column to the right, and merge two cells together. My issue is how do I <select the two cells in the single column to merge them? Thank you. "Ryan H" wrote: I'm not 100% sure what you are wanting but I think you want to merge the cell to the right of the activecell with the cell one row above that cell, right? If so, you can use this line of code. Union(ActiveCell.Offset(0, 1), ActiveCell.Offset(-1, 1)).MergeCells = True Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "Steve" wrote: Morning all. I'm making a user form, and want to select a cell to place my equation, then with that selection choice, offset upwards, and to the side, to select and merge two sets of two cells, each. I understand with my selection that I'd use the following: activecell.offset(0,1).select to get my first cell selection. But how do I retain that initial selection, and then offset one more up, to then merge those two cells? Thank you. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
beforerightclick and selection change issue | Excel Programming | |||
combo box selection issue | Excel Programming | |||
Selection.Copy issue | Excel Programming | |||
Multiple range selection issue | Excel Programming | |||
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. | Excel Programming |