我正在尝试创建一个按钮,根据我给他的日期和年份进行自动工作安排。它使用字符串中的名称创建一个新工作表 - 年份
Sub Create_Arran_Click()
Dim year As String
Dim sdate As Date
Dim row As Integer
year = Worksheets("Main").Cells(17, 4)
sdate = Worksheets("Main").Cells(18, 4)
Sheets.Add.Name = year
For i = 1 To 56
row = ((i - 1) * 12) + 2
Worksheets(year).Cells(row, 1) = "week " & i
Worksheets(year).Cells(row + 1, 1) = "day"
Worksheets(year).Cells(row, 1).Font.Bold = True
For j = 2 To 15
(!)Range(Cells(row, j), Cells(row, (j + 1))).Merge
Worksheets(year).Cells(row, j) = sdate + (j - 2)
(!)Range(Cells(row + 1, j), Cells(row + 1, j + 1)).Merge
Worksheets(year).Cells(row + 1, j) = Weekday(sdate + (j - 2), vbSunday)
j = j + 2
Next
sdate = sdate + 7
Next'
问题是标有“!”的行 没有在“年”表中进行合并。我尝试了几件事,例如:
'Worksheets(year).Range(Cells(row, j), Cells(row, (j + 1))).Merge
或 sheet(year).Range(Cells(row, j), Cells(row, (j + 1))).Merge 或 Worksheets(year).activate
但没有什么可以帮助任何人?