工作表选项卡名称更改基于单元格值

时间:2019-02-13 08:19:01

标签: excel vba

我想基于单元格值更改工作表选项卡名称,仅在工作表1中其他单元格没有更改

没事

Public Sub ChangeSheetNames()
    Dim ws As Worksheet

    'lastRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
    'For i = 2 To lastRow
    On Error Resume Next
    For Each ws In Worksheets
    'ws.Tab = ws.Cells(i, 2)

       If ws.Range("A2").Value <> "" Then
          ws.Name = ws.Range("A2").Value
       End If

    Next ws
End Sub

仅更换1张纸,我至少需要更换50张纸

1 个答案:

答案 0 :(得分:0)

尝试此宏:

sheet = ":/some_style_sheet_file.qss"
with open(sheet, "r") as f:
    style = sheet.read()

app = QApplication([])
# ...
app.setStyleSheet(style)
sys.app(app.exec_())