If IsEmpty(Cells(8, M8).Value) And IsEmpty(Cells(14, M8).Value) = True Then
Sheets("Schedule").Cells(8, M8).Value = info
Sheets("Schedule").Range(Cells(9, M8), Cells(14, M8)).Value = ","
Sheets("Schedule").Range(Cells(8, M8), Cells(14, M8)).Interior.Color = rcolor
Sheets("Schedule").Range(Cells(8, M8), Cells(14, M8)).BorderAround Weight:=xlMedium
M8 = M8 + 1
Else
M8 = M8 + 1
End If
并且我想要而不是使用“info”init在单元格下面的空单元格上打印逗号,我希望所有信息都打印到主单元格下面的单元格上,因为信息有很多单词/又名相当大
答案 0 :(得分:0)
首先,在多次引用工作表时,应使用With
。此外,它有助于将Cells()
锚定到您希望它们所在的工作表上:
With Sheets("Schedule")
If IsEmpty(.Cells(8, M8).Value) And IsEmpty(.Cells(14, M8).Value) Then
.Cells(8, M8).Value = info
.Range(.Cells(9, M8), .Cells(14, M8)).Value = ","
.Range(.Cells(8, M8), .Cells(14, M8)).Interior.Color = rcolor
.Range(.Cells(8, M8), .Cells(14, M8)).BorderAround Weight:=xlMedium
M8 = M8 + 1
Else
M8 = M8 + 1
End If
但是对于你的主要问题,你能澄清一下吗?为什么不将","
替换为info
?也许发布一个样本表,预测输出结果如何?