åããã¼ã¿ã®ã»ã«ãçµåãã
ä»åã¯é£æ¥ããã»ã«ã®ãã¼ã¿ãåãã§ããã°ãã»ã«çµåãããã¨ããã³ã¼ããä½ã£ã¦ã¿ããã¨æãã¾ãã
ãããã
ãã»ã«çµåã¯ãªãã¹ãé¿ããã¹ãã
ãããã«ã»ã«çµåããããæ°ã¯æ» ãã§ã»ããã
ãæåãããã®æ©è½ãç¡ããã°ããã£ãã
ã¨ããããããªå£°ãããè³ã«ãã¾ãã
確ãã«ãå¤ãã®äººã§ãã¼ã¿ãå
±æããããããããªã¨ã¯ã»ã«ã·ã¼ãã§ããã°ãã¨ã¯ã»ã«ã®ä¾¿å©ãªæ©è½ã殺ããã¦ãã¾ããæãã¬è¿·æãããã¦ãã¾ããã¨ãããã¾ãã
ãããã使ãæ¨ã¦ã§ãä»äººã«æ¸¡ããããªãã®ã§ãªããã°ãè¦ãããããããã«ã¡ãã£ã¨ãããçµåããã£ã¦ããããããã¨ããæãããã£ãããã¾ãã
Â
å®éãç§ã¯ããããã¾ããï¼âãï¼
Â
ã ããã¨ãã£ã¦ãæåã§1åãã¤çµåãã¦ããã®ãé¢åãããã§ãããªã®ã§ã縦æ¹åï¼ã¾ãã¯æ¨ªæ¹åï¼ã«é£æ¥ããã»ã«ã®ãã¼ã¿ãåããªãã»ã«çµåãããã¨ããã³ã¼ããä½ã£ã¦ã¿ã¾ãããç¦å¿ãç©æ¥µçã«ç ´ãããã§æ°ãå¼ãã¾ããã©ã・・・・・・ã
Sub åããã¼ã¿ã®ã»ã«ãçµåãã() Dim å As Long Dim è¡ As Long Dim è¡çµ As Long Dim åçµ As Long Dim myUni As Range Application.DisplayAlerts = False If Selection.Rows.Count > 1 And Selection.Columns.Count = 1 Then 'ä¸æ¹åã«é¸æããã¨ãã®å¦ç å = Selection.Column è¡ = Selection.Row + 1 è¡çµ = Selection.Rows(Selection.Rows.Count).Row Do While è¡ <= è¡çµ If Cells(è¡ - 1, å).MergeArea(1).Value = Cells(è¡, å).MergeArea(1).Value Then If myUni Is Nothing Then Set myUni = Range(Cells(è¡ - 1, å), Cells(è¡, å)) Else Set myUni = Union(myUni, Cells(è¡, å)) End If Else If Not myUni Is Nothing Then myUni.Merge Set myUni = Nothing End If End If è¡ = è¡ + 1 Loop ElseIf Selection.Rows.Count = 1 And Selection.Columns.Count > 1 Then 'å³æ¹åã«é¸æããã¨ãã®å¦ç è¡ = Selection.Row å = Selection.Column + 1 åçµ = Selection.Columns(Selection.Columns.Count).Column Do While å <= åçµ If Cells(è¡, å - 1).MergeArea(1).Value = Cells(è¡, å).MergeArea(1).Value Then If myUni Is Nothing Then Set myUni = Range(Cells(è¡, å - 1), Cells(è¡, å)) Else Set myUni = Union(myUni, Cells(è¡, å)) End If Else If Not myUni Is Nothing Then myUni.Merge Set myUni = Nothing End If End If å = å + 1 Loop End If If Not myUni Is Nothing Then 'è¡çµã¾ãã¯åçµãå«ãã»ã«ã®çµå myUni.Merge End If End Sub
â»ã³ã¼ãã®ä½¿ç¨æ¹æ³
SubããEnd Subã¾ã§ãã³ãã¼ããæ¨æºã¢ã¸ã¥ã¼ã«çã«è²¼ãä»ãã¦ä½¿ç¨ãã¦ä¸ããããªãããã¯ãã§å®è¡ããå¦çã¯ãå ã«æ»ãããã¨ãã§ãã¾ãããå®è¡åã«ä¸æ¦ä¿åãããç´ãã®ã§ããç¶æ ã«ãã¦ããã¦ä¸ãããæ¨æºã¢ã¸ã¥ã¼ã«ã«ã³ã¼ããè²¼ãä»ãã¦ãã¯ãã使ç¨ããæ¹æ³ã¯ãã¡ãã
Â
ããã°ã©ã ã®èª¬æ
- å²æ
Â
å®è¡é¢¨æ¯
縦æ¹åã»æ¨ªæ¹åã®ã©ã¡ãå´ã«é¸æãã¦ãããã¯ããã°ã©ã ãèªåå¤å¥ãã¦ããã¾ãã
éè¨ã®æ©è½ãç ç²ã«ãã¦ãå¹é£çã«è¦ãããããã ãã®ä»æã®ãªãã³ã¼ãã§ããï¼ï¿£ï½ï¿£;ï¼
Â
 åé ã§ã触ãã¾ããããå ¬ã®å ´ã§ã»ã«çµåãä¹±ç¨ããã¨è¬ã®å¢åã«å½ãçããã¾ãã®ã§ããã®ç¹ã¯æ³¨æãã¦ä¸ããã