【发布时间】:2020-02-23 01:40:54
【问题描述】:
对于 Excel 的 VBA,我非常陌生。但是,我在 VBA 上阅读了尽可能多的内容,但仍然无法理解如何编写此代码。我遇到的问题之一是语法本身。
目前,我有一个电子表格,其中的信息不是恒定的,我希望能够在此电子表格中搜索特定单词,然后 Excel 将一个单元格向右移动并输入一些文本。如果特定单词不存在,那么我希望 VBA 什么都不做,继续搜索下一个单词。
所以,这就是我的想法,我只是不知道如何用正确的语法写出来:
Option Explicit
Sub SortAndLabel()
'Here is where I get lost as far as syntax goes so I will just type in what I'm wanting it to do...
Search the current worksheet for "12345 Total"
If "12345 Total" is not found then Do Nothing
Else
'Move 1 cell to the right
ActiveCell.Offset(0,1)
'Then enter in the following text (I don't know the proper syntax for this)...
Enter text "Electric"
End If
如果您能提供任何帮助,我将不胜感激。
【问题讨论】:
-
开始使用宏记录器生成代码。
标签: excel vba subroutine