vba excel:如何用文本填充两行单元格

问题描述:

我需要使用VBA在我的excel表中创建一个标题。似乎很简单,但是当我这样做

I need to make a header in my excel sheet using VBA. Seems pretty simple, but when I do this

Worksheets("New_Students").Range("A1").Value = "studentID"
Worksheets("New_Students").Range("B1").Value = "ISUID"

只有第一行工作,而不是第二行。我忘记了什么?

only the first line works and not the second one. What am I forgetting?

尝试这样:


  1. 在excel应用程序中,转到功能区上的开发人员选项卡,然后单击记录宏。

  2. 手动输入两个单元格中的值。

  3. 点击停止录制并查看它创建的宏。

这将显示您可以使用的VBA代码,您可以比较它你有什么要麻烦拍摄。

This would show you VBA code that will work and you can compare it to what you have in order to trouble shoot.

这被称为记录宏,可以非常有助于解决问题。事实上,我建议几乎每次在这里提出问题之前这样做。

This is called recording a macro and can be very helpful in solving problems. In fact I would suggest doing so almost every time before asking a question here.