vba - 如何在 VBA 中更改标题

标签 vba excel

关闭。这个问题需要details or clarity .它目前不接受答案。












想改进这个问题?通过 editing this post 添加详细信息并澄清问题.


7年前关闭。







Improve this question




我在将列标题修改为我想要的命名时遇到问题。这是我的 table :

st_name  st_id  st_num
Alex      112   1113
Alice     110   1132

预期输出:
Name      ID    Number
Alex      112   1113
Alice     110   1132

如何重命名标题,如预期的输出表中所示。

最佳答案

如何实现您所需要的有几种变体

请注意,该示例基于使用的范围 "A1:C1"
1 个变体

Cells(1, 1).Value = "Name"
Cells(1, 2).Value = "ID"
Cells(1, 3).Value = "Number"

2 变体
Cells(1, "A").Value = "Name"
Cells(1, "B").Value = "ID"
Cells(1, "C").Value = "Number"

3 变体
Range("A1").Value = "Name"
Range("B1").Value = "ID"
Range("C1").Value = "Number"

4 变体
[A1].Value = "Name"
[B1].Value = "ID"
[C1].Value = "Number"

5 变体,作为替代方案,以防范围不断变化
[A1:C1].Value = Split("Name ID Number")

或者
Range("A1:C1").Value = Split("Name;ID;Number",";")

或者
Range(Cells(1, 1), Cells(1, 3)).Value = Split("Name ID Number")

或者
Range(Cells(1, "A"), Cells(1, "C")).Value = Split("Name ID Number")

或者
[A1:C1].Value = Split("Name ID Number")

...等等...取决于需要完成的任务

关于vba - 如何在 VBA 中更改标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30448673/

相关文章:

vba - 显示宏正在执行的更新

Excel VBA : copy lots of columns

c# - 使用嵌入式资源打开 Excel 工作簿文件

excel - 使用 Excel Power Query 将 Parse 类导出到 Excel?

excel - 如何更改将鼠标悬停在评论框上时的位置?

vba - 在 VBA Access 中使用 .text 和 .value 之间的区别

ms-access - 我无法在 VBA Access 中使用 UBound() 函数。好像没有被识别

excel - 自动填充动态数据范围内的增量数

excel - 在 Power Query 中引用函数时出现问题

python - 根据内容在word中添加文字