Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,814
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default 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
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
beforerightclick and selection change issue DennisB[_2_] Excel Programming 0 October 28th 08 02:42 PM
combo box selection issue davethewelder Excel Programming 2 April 7th 08 05:49 PM
Selection.Copy issue greyhound girl Excel Programming 6 July 27th 07 07:27 PM
Multiple range selection issue SPV Excel Programming 5 June 28th 07 05:14 AM
Excel VBA - Range(Selection, Selection.End(xlDown)).Name issue. jonH Excel Programming 3 June 7th 04 09:13 PM


All times are GMT +1. The time now is 04:41 PM.

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"