EXCEL sheet List語法問題

我有以下巨集語法

Sub SheetList()

x = Sheets.Count

For i = 1 To x

Cells(i, 2) = Sheets(i).Name

Next

End Sub

可是每次秀出來的答案都會出現在B1的欄位裡

我想把它改為從B2開始秀出答案,這樣又該如何修改??

Update:

那再請問,若是我要把這個list放在特定的sheet裡要再加上什麼?

1 Answer

Rating
  • 1 decade ago
    Best Answer

    你要將

    Cells(i, 2) = Sheets(i).Name

    改成

    Cells(1+ i, 2) = Sheets(i).Name

    就可以了

    2009-09-08 17:56:58 補充:

    在cells前面加上你要放的sheet就可以了

    例如:

    Sub SheetList()

    x = Sheets.Count

    For i = 1 To x

    Sheet2.Cells(1 + i, 2) = Sheets(i).Name '這樣就會在sheet2裡面秀出來了

    Next

    End Sub

    Source(s): 自己
Still have questions? Get your answers by asking now.