Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / November 2006

Tip: Looking for answers? Try searching our database.

How to know width and height of merge cells?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bpk. Adi Wira Kusuma - 12 Nov 2006 13:39 GMT
I merge 2 cells, A1+B1. I wanna know width and height of the merge cells.
How to know
it?
Bob Phillips - 12 Nov 2006 13:47 GMT
Dim cell As Range
   If ActiveCell.MergeCells Then
       For Each cell In ActiveCell.MergeArea
           MsgBox cell.Address & " width = " & cell.ColumnWidth & " height
= " & cell.Height
       Next cell
   End If

Signature

HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

> I merge 2 cells, A1+B1. I wanna know width and height of the merge cells.
> How to know
> it?
Bpk. Adi Wira Kusuma - 12 Nov 2006 14:07 GMT
if I make width a cell equal as sum of each width
cell in merge cell, so is width a cell same width merge cell?

> Dim cell As Range
>     If ActiveCell.MergeCells Then
[quoted text clipped - 14 lines]
> > How to know
> > it?
Dave Peterson - 12 Nov 2006 14:45 GMT
Or you could use the width of the merged area.

Option Explicit
Sub testme()

   Dim myTotalWidth As Double
   Dim myTotalHeight As Double
   Dim myCell As Range
   Dim myMergedCells As Range
   
   With ActiveSheet
       Set myMergedCells = .Range("a1:c3")
   End With
   
   myMergedCells.Merge
   myTotalWidth = 0
   For Each myCell In myMergedCells.Rows(1).Cells
       myTotalWidth = myTotalWidth + myCell.Width
   Next myCell
   
   myTotalHeight = 0
   For Each myCell In myMergedCells.Columns(1).Cells
       myTotalHeight = myTotalHeight + myCell.Height
   Next myCell
   
   'are they equal?
   MsgBox myTotalHeight & "=" & myMergedCells.Height & vbLf _
           & myTotalWidth & "=" & myMergedCells.Width
   
End Sub

> if I make width a cell equal as sum of each width
> cell in merge cell, so is width a cell same width merge cell?
[quoted text clipped - 19 lines]
> > > How to know
> > > it?

Signature

Dave Peterson

Bpk. Adi Wira Kusuma - 12 Nov 2006 15:18 GMT
Try to set columnwidth a cell with the value!!!
are they equal?

Hi, Dave............. Why does property "width" always be 144. Where does
the value come from?

> Or you could use the width of the merged area.
>
[quoted text clipped - 54 lines]
>
> Dave Peterson
Dave Peterson - 12 Nov 2006 15:27 GMT
Try widening some columns (and increasing rowheights) and try it again.

> Try to set columnwidth a cell with the value!!!
> are they equal?
[quoted text clipped - 60 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Bpk. Adi Wira Kusuma - 12 Nov 2006 16:47 GMT
May be, u dont understood that I want.
I merge 2 cells (A1+B1). eg: width of the cell is 20 ( width of A1 is 10,
and width of B1 is 10). So if I make/set width of E1 to be 20, why its look
as no equal. Because when I type in both cells with the same font, so number
character in the cell is not equal.

> Try widening some columns (and increasing rowheights) and try it again.
>
[quoted text clipped - 66 lines]
>
> Dave Peterson
Dave Peterson - 12 Nov 2006 17:29 GMT
Maybe you want .columnwidth.

> May be, u dont understood that I want.
> I merge 2 cells (A1+B1). eg: width of the cell is 20 ( width of A1 is 10,
[quoted text clipped - 78 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Bpk. Adi Wira Kusuma - 12 Nov 2006 17:58 GMT
Yes, the main of my purpose is how to make height/width of a cell egual to
height/width of a merge cell. eg: width of merge cell is 20 ( width of A1 is
10, and width of B1 is 10). So I wanna make/set width of E1 to be equal to
the marge cell.

How to do it?

> Maybe you want .columnwidth.
>
[quoted text clipped - 84 lines]
>
> Dave Peterson
Dave Peterson - 12 Nov 2006 20:07 GMT
Option Explicit
Sub testme()

   Dim TotalColumnWidth As Double
   Dim myCell As Range
   
   With ActiveSheet
       TotalColumnWidth = 0
       For Each myCell In .Range("a1").MergeArea.Rows(1).Cells
           TotalColumnWidth = TotalColumnWidth + myCell.ColumnWidth
       Next myCell
       .Range("E1").ColumnWidth = TotalColumnWidth
   End With
   
End Sub

> Yes, the main of my purpose is how to make height/width of a cell egual to
> height/width of a merge cell. eg: width of merge cell is 20 ( width of A1 is
[quoted text clipped - 97 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Ragdyer - 13 Nov 2006 01:10 GMT
Why does this sound like someone is trying to overcome *the* error message
of:

<<"Cannot paste because the copy area and the paste area are not the same
size and shape.">>
when using merged cells?
Signature

Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------

> Option Explicit
> Sub testme()
[quoted text clipped - 113 lines]
> > >
> > > Dave Peterson
Dave Peterson - 13 Nov 2006 02:17 GMT
I didn't guess that.  I figured that the OP was making some kind of form that
needed to be pretty (whatever that means).

> Why does this sound like someone is trying to overcome *the* error message
> of:
[quoted text clipped - 141 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

Dave Peterson - 12 Nov 2006 16:18 GMT
ps.  .width is a readonly property.  You may want to look at .columnwidth, too.

> Try to set columnwidth a cell with the value!!!
> are they equal?
[quoted text clipped - 60 lines]
> >
> > Dave Peterson

Signature

Dave Peterson

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.