Visual studio 在excel vb 2019中着色、使单元格样式正常并合并特定范围

Visual studio 在excel vb 2019中着色、使单元格样式正常并合并特定范围,visual-studio,Visual Studio,有人能把这段代码缩短吗 对于j=1到7 formatb=操作系统范围(“b”和Lr+j) formatb.Interior.Color=System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightYellow) formatb=操作系统范围(“d”和Lr+j) formatb.Interior.Color=System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Light

有人能把这段代码缩短吗
对于j=1到7 formatb=操作系统范围(“b”和Lr+j) formatb.Interior.Color=System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightYellow) formatb=操作系统范围(“d”和Lr+j) formatb.Interior.Color=System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightYellow) formatb=操作系统范围(“c”和Lr+j) formatb.Interior.Color=System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightYellow)

        formatRange = oS.Range("b" & Lr + j)
        formatRange.BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlMedium, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic)
        formatRange = oS.Range("c" & Lr + j)
        formatRange.BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlMedium, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic)
        formatRange = oS.Range("d" & Lr + j)
        formatRange.BorderAround(Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Microsoft.Office.Interop.Excel.XlBorderWeight.xlMedium, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic, Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexAutomatic)

        oS.Range("a" & Lr + j).Style = "Normal"
        oS.Range("e" & Lr + j).Style = "Normal"
        oS.Range("f" & Lr + j).Style = "Normal"
        oS.Range("g" & Lr + j).Style = "Normal"
        oS.Range("h" & Lr + j).Style = "Normal"
        oS.Range("i" & Lr + j).Style = "Normal"
        oS.Range("j" & Lr + j).Style = "Normal"
        oS.Range("k" & Lr + j).Style = "Normal"
        oS.Range("l" & Lr + j).Style = "Normal"
        oS.Range("m" & Lr + j).Style = "Normal"
        oS.Range("n" & Lr + j).Style = "Normal"
        oS.Range("o" & Lr + j).Style = "Normal"

        formatRange = oS.Range("a" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("e" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("f" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("g" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("h" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("i" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("j" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("k" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("l" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("m" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("n" & Lr + j)
        formatRange.Merge()
        formatRange = oS.Range("o" & Lr + j)
        formatRange.Merge()
    Next j