Tag: 转到

Excel VBA:在for循环中跳转:“Next without For” – 我在做什么错误?

我真的不知道为什么VBA编译器因为GoTo Jump而唠叨我,。 counter2 = 0 If (counter1 > 1) Then For i = 0 To (MaxLastCell – 4) If (IncompleteRows(i) = 1) Then If ((counter2 > 1) And (counter2 < counter1)) Then x = x + ", " + CLng(i) counter2 = counter2 + 1 GoTo Jump End If If ((counter2 > 1) And (counter2 […]

VBA InputBox运行错误(错误的variablestypes)重新运行InputBox

嘿,伙计们,我要写我在VBA的第一个基本步骤,我遇到了以下问题。 Test1: qm = InputBox("Wie viele Quadrat Meter hat die Wohnung?" & vbLf & "Bitte geben sie die QM Zahl an.", Angabe) If IsError(qm) Then GoTo Test1 qm被定义为一个Integer ,= 0,下面有一个Select Case mutilple选项,它将qm从1-600改为一个数字。 当InputBox运行时,我input一个像“嘿家伙”的Word,Excel给了我错误13(运行时错误13':types错配)。 我的目标是在崩溃时重新运行InputBox,并给用户一个新的机会给一个数字正确的input。 (就像它崩溃,你会得到一个msgbox它说:“对不起你的input不可用,请重试”,它会跳回到味精框) 我试图find堆栈溢出的适合的解释和谷歌search,但无法find解决scheme相同的问题。 如果你能帮我解决问题,或者给我一个合适的解释,我会非常感激。

error handling不工作的VBA

我试图循环用户回来,如果它找不到你在找什么。 我到目前为止,但我如何循环回来让用户重新input信息,并提示他们与一个MsgBox以及? Range("A1").Select Repeat: Findcata = InputBox("Please Input What Section You Want To Add To") If Findcata = "" Then Exit Sub Set RangeObj = Cells.Find(What:=Findcat, After:=ActiveCell, _ LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, _ SearchDirection:=xlNext, MatchCase:=False) If RangeObj Is Nothing Then GoTo Repeat Else: RangeObj.Select

VBA“编译错误:标签未定义”

我有一个VBAmacros给我那个错误信息。 Sub Function1() ' Give the user macro options based on how fast or slow the computer ' is using advanced conditional compiling vuserChoice = MsgBox("This macro by default treats all numbers as decimals for maximum precision. If you are running this macro on an old computer, you may want to declare numbers as singles, […]

VBA嵌套错误转到

我有应该嵌套错误检查的VBA代码,但它没有。 代码如下所示。 但是,每当在错误中发生错误(例如,错误在循环中被触发,就会发生SmallError,并且在SmallError中发生错误)。不使用第二个GoTo。 错误然后打破代码。 例如: 错误在循环中 去小错误 在SmallError错误 代码中断(这里代码应该GoTo致命错误) Sub DoThings() On Error GoTo SmallError 'Coding Happens Do While(conditionhere) 'Looping things happen GoTo LoopResume SmallError: source = Err.source descript = Err.Description On Error GoTo Fatal Error 'Small error processing happens Resume LoopResume FatalError: source = Err.source descript = Err. Description On Error GoTo ExitError 'Fatal […]

On Error GoTo语句仍在执行,虽然没有生成错误

我有我的代码如下,奇怪的是Errorhandler过程仍在执行,即使代码中没有错误…有什么问题? 在没有任何error handling程序的情况下运行代码不会生成任何错误,但是当包含error handling语句时,仍然会显示Errorhandler下的msgbox ! 码 Public Sub ExportGraphs(Optional PivotExport As Boolean) ' Exports only graphs on the "Mainwindow" sheet to a new worksheet Dim wsh As Worksheet: Set wsh = Sheets.Add Dim source_sht As Worksheet: Set source_sht = Sheets("Mainwindow") ActiveWindow.Zoom = 70 On Error GoTo Errorhandler With wsh If source_sht.OLEObjects("Btn_CurrentTime").Object.Value = True Then .Name […]

转到VBA中的<行号>

从VBA帮助文件: 去声明 无条件地分支到程序中的指定行。 句法 去 _ 行 _ 所需的参数可以是任何行标签或行号。 备注 GoTo只能在其出现的过程中分行。 我的问题是,如何跳转到使用GoTo的行号? (我知道如何跳到标签上。) (注意:我是为了好奇而问这个问题,我不打算以这种方式实际使用GoTo 。)