Attribute VB_Name = "Module1" Sub 表をHTML形式に変換() Const maxRowCheck = 200 Const maxColCheck = 100 ReDim spanInfos(maxRowCheck, maxColCheck) ReDim tableHtml(maxRowCheck + 2) Dim maxRow As Long, maxCol As Long Dim numRow As Long, numCol As Long Dim strAddress As String Dim posC As Long, posColon As Long Dim span1stRow As Long, span1stCol As Long Dim thisRow As Long, thisCol As Long Dim thisLine As String Dim thtd As String Dim cellText As String Dim spanInfo As String Dim tempColor As String, styleBGColor As String, styleColor As String '表のサイズを取得 For numRow = 1 To maxRowCheck For numCol = 1 To maxColCheck If Cells(numRow, numCol) <> "" Then If maxRow < numRow Then maxRow = numRow If maxCol < numCol Then maxCol = numCol End If Next numCol Next numRow 'rowspanとcolspanに関する情報を取得 For numRow = 1 To maxRow For numCol = 1 To maxCol strAddress = Cells(numRow, numCol).MergeArea.Address(ReferenceStyle:=xlR1C1) posC = InStr(strAddress, "C") '「C」の位置 posColon = InStr(strAddress, ":") '「:」の位置 If posColon Then 'コロンあり=セル結合あり span1stRow = CInt(Mid(strAddress, 2, posC - 2)) span1stCol = CInt(Mid(strAddress, posC + 1, posColon - posC - 1)) For thisRow = span1stRow To numRow For thisCol = span1stCol To numCol If thisRow = span1stRow And thisCol = span1stCol Then spanInfos(thisRow, thisCol) = " rowspan=" & (numRow - span1stRow + 1) _ & " colspan=" & (numCol - span1stCol + 1) Else spanInfos(thisRow, thisCol) = "null" End If Next thisCol Next thisRow Else spanInfos(numRow, numCol) = "" End If Next numCol Next numRow 'HTML(tableタグ)を生成 tableHtml(0) = "