返回列表 上一主題 發帖

[發問] 儲存格跨欄置中(可活動欄位)

[發問] 儲存格跨欄置中(可活動欄位)

請教各位高手
想要選取E1:G1儲存格跨欄置中
知道(用錄的)大概這樣寫
Range("E1:G1").Select
With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlCenter
            .WrapText = False
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = True
        End With

但現在想要不要只局限在到G1,未來可能H1,I1,J1....等等
所以想要先讀有多少欄
Do Until ActiveSheet.Cells(2, col) = ""
      col = col + 1
     Loop
      ba = col - 6
再利用欄位選取
請教這樣要怎麼打?
Range("E1:" & [E1].Offset(, ba)).Select
不能這樣寫嗎?

謝謝各位

Range(Cells(2, 1), Cells(2, Columns.Count).End(xlToLeft)).Select

TOP

回復 2# linyancheng

謝謝您
會應用了~

TOP

        靜思自在 : 人生沒有所有權,只有生命的使用權。
返回列表 上一主題