VB:将2个vb动作的命令组合成1个同时动作 [英] VB: combine commands for 2 vb actions, into 1 simultaneous action

查看:86
本文介绍了VB:将2个vb动作的命令组合成1个同时动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

喜 我试图弄清楚如何将命令组合成一个动作:  Scrollrow& cell.activate

  i am trying to figure out how to combine commands into one action for:  Scrollrow & cell.activate

我想将以下两项合并,以实现1次无缝操作。 我一直在寻找可能做到这一点的任何命令。 不确定是否需要UDF,但必须有一些方法来加入命令。 我不想用: 
ScreenUpdating = False   屏幕中断。 对此的回答将有多种用途。

I would like to combine the two items below to allow 1 seamless action.  i have been looking for any commands that might do this.  not sure if a UDF is required, but there must be some way to join the commands.  i do not wish to use:  ScreenUpdating = False    for the screen disrupt.  the answer to this will serve multiple uses.

尝试/尝试/查看的一些事情:  JOIN,  GOTO,  UNION, 试图结合DIMS和amp;套,  UDF的...

some things tried / trying / looking at:  JOIN,  GOTO,  UNION,  trying to combine DIMS & SETS,  UDF's ...

我知道你结合了一些简单的项目,比如RANGE()。select  &安培;  SELECTION.copy 只是:  RANGE.copy,  :) 所以在一个单词问题中,例如:

i know you combine some simple items like RANGE().select  &  SELECTION.copy  into just:  RANGE.copy,  :)  so in a word problem eg:

   将arG1调暗为?,  arG2为?:  arG3为?: 设置arG3 =(arG1& arG2)

    Dim arG1 as ?,  arG2 as ?:  arG3 as ?:  set arG3 = (arG1 & arG2)

      'ActiveWindow.ScrollRow = namX.row - 1    'arg1

     'namX.Select    'arg2

      'ActiveWindow.ScrollRow = namX.row - 1    'arg1
     ' namX.Select    'arg2

   运行arG3

    RUN arG3

作为它的立场: 项目1执行然后在项目2赶上时暂停。   提前谢谢。

AS IT STANDS:  item 1 performs then there is pause while item 2 catches up.    thanks in advance.

我可以提供更多有关(粗略)创意的信息。之后可以发布工作用途副本。 对于这个例子我有:

i can give more notes on what i have for (rough) ideas & can post afterwards, a working use copy.  for this example i have:

子测试()

    Dim E7 As String:E7 = RANGE(" E7")    'workcells show eg:  BH100:BH500    &安培;    BH16

    Dim G7 As String:G7 = RANGE(" G7")    '公式例如: 见下文 


    Dim E7 As String: E7 = RANGE("E7")    'workcells show eg:  BH100:BH500    &    BH16
    Dim G7 As String: G7 = RANGE("G7")    'formula eg:  see below 

    Dim namX As RANGE:设置namX = RANGE(E7).find(what:= RANGE(G7).Value,LookAt:= xlWhole)

    Dim namX As RANGE: Set namX = RANGE(E7).find(what:=RANGE(G7).Value, LookAt:=xlWhole)

   如果不是namX则没有那么   

    If Not namX Is Nothing Then   

      ActiveWindow.ScrollRow = namX.row - 1    'ITEM 1

      namX.Select    '项目2

      ActiveWindow.ScrollRow = namX.row - 1    'ITEM 1
      namX.Select    'ITEM 2

   结束如果

    end if

结束子

workcell例如: 

workcell eg: 

= SUBSTITUTE(SUBSTITUTE(CELL(" address",$ BH $ 100)," $",""),"","") &安培;":"&安培;替换(SUBSTITUTE(CELL(QUOT;地址]按钮,$ BH $ 500)," $",""),"","")

=SUBSTITUTE(SUBSTITUTE(CELL("address",$BH$100),"$",""),"","")&":"&SUBSTITUTE(SUBSTITUTE(CELL("address",$BH$500),"$",""),"","")

推荐答案

你好
Davexx,

你曾经问过,"如何将命令组合成一个动作:  Scrollrow& cell.activate"。

you had asked that,"how to combine commands into one action for:  Scrollrow & cell.activate".

使用&你只能  concatenate。

using & you can only  concatenate .

但它不能将两个命令组合起来并像单个命令一样执行。

but it will not work to combine both commands and execute like a single command.

它用于连接一个或多个字符串。

it is use to concatenate the string or values.

所以在这里你很想理解这个运算符的用法。

so here you are miss understanding the use of this operators.

没有办法将两个不同的命令组合成单个命令并一起执行因为它们是一个单一的命令。

there is no way to combine two different commands in to single command and execute together as they are one single command.

它们将一个接一个地执行。

they will execute one after another.

首先它将滚动行然后它将激活单元格。

like first it will scroll the row and then it will activate the cell.

vba中有break和combined语句用于中断和组合语句。但它不会按你的意愿工作。它们也是一步一步执行的。

there are break and combining statements in vba that use to break and combine the statements. but it will not work as you desired. they also execute step by step.

就像声明太长,然后我们可以使用"_" (下划线)打破它,以便我们可以轻松地在多行中看到它。

like if the statement is too long then we can use "_" (underscore) to break it so that we can see it in multi lines easily.

示例:

  cmd.CommandText = _
        "SELECT * FROM Titles JOIN Publishers " _
        & "ON Publishers.PubId = Titles.PubID " _
        & "WHERE Publishers.State = 'CA'"

要合并我们可以使用":" (冒号)。

to combine we can use ":" (colon).

Public Const cdbArea = 1: Public Const cdbDist = 2: Public Const cdbChange1 = 4

但它仍将独立执行。它不会作为单个命令执行。

but still it will execute independently. it will not execute as a single command.

它只是用来正确查看,阅读,理解代码。

it is just use to see, read, understand the code properly.

所以没有实现你的要求的方法。

so there is no way to achieve your requirement.

希望通过这个建议你得到你的问题的答案。

hope by this suggestion you got the answer for your question.

问候

迪帕克 


这篇关于VB:将2个vb动作的命令组合成1个同时动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆