Tag: 运行时错误

电子邮件范围,而不是行

我正在尝试运行Excel工作簿的表格2,以便向客户发送电子邮件范围。 范围将是A1:B30,C1:D30,E1:F30等,其帐号在A1和电子邮件在B1和下面的信息。 每次我尝试运行电子邮件时,都会出现: 运行时错误1004 然后继续出错 对象已被移动或删除 是否有另一种电邮范围或方式来修改此代码的方式? Sub EmailRanges() Dim cr As Range Set cr = [b1] ActiveWorkbook.EnvelopeVisible = True Do While cr <> "" cr.Offset(, -1).Resize(30, 2).Select With ActiveSheet.MailEnvelope .Introduction = " Good Morning" .Item.To = cr .Item.Subject = "Just testing, sorry for filling you inbox ^_^ " .item.Send ' to send .Item.Display ' […]

#REF! 粘贴作为价值,但循环时没有看到

我刚刚在我的部门发布了一个Excel加载项,我已经在最近2个月的时间里检查了大约30个validation错误。 我在所有情况下都处理错误陷阱(因为它现在正在出现),但是今天我收到了一个可怕的唤醒电话,因为我收到了两个重要的错误的自动电子邮件(这是我在error handling中构build的一个function)。 我已经在这里发布了关于第一个bug的问题,并且认为我会为第二个bug提出一个新的问题,因为它与第一个bug无关。 我的代码如下 Private Sub symbolCheck() On Error GoTo ErrHandler Application.StatusBar = "(3/16) Checking for invalid symbols" Dim MyArray As Variant Dim replacementsMade As Boolean replacementsMade = False MyArray = ActiveSheet.UsedRange For i = LBound(MyArray) To UBound(MyArray) For j = LBound(MyArray, 2) To UBound(MyArray, 2) If MyArray(i, j) <> "" Then 'Apostrophe/Closing Single […]

复制并粘贴最后一行,错误91

我正在试图复制和粘贴范围的值范围内的最后一行,这意味着行数会有所不同,但列的数量将保持不变。 我已经写了这样做的代码继续返回错误: 对象variables或未设置块variables 这个错误是什么意思,我该如何解决? Sub update() Dim LR As Range Dim Revise As Range LR = Cells(Rows.Count, "M").End(xlUp).Row Set Revise = Range("M1:M" & LR) Revise.Copy Sheets(Weekly).Select Cells(1,1).PasteSpecial xlPasteAll End Sub

VBA中的构造函数 – 运行时错误91“对象variables未设置”

我正在尝试使用面向对象的概念在Excel VBA中编写一些代码。 所以我想用构造函数初始化我的对象,就像我们通常在Java中所做的那样。 但是,我发现在VBA中提供的默认Class_Initialize() Sub不带参数。 经过一番search,我发现这个问题的答案提出了一个很好的select。 这里是我的工厂模块(我命名它造物主 )的一个例子: Public Function CreateTool(ToolID As Integer) As cTool Set CreateTool = New cTool CreateTool.InitiateProperties (ToolID) '<= runtime error 91 here End Function 类cTool : Private pToolID As Integer Private pAttributes As ADODB.Recordset Private pCnn As ADODB.Connection Public Sub InitiateProperties(ToolID As Integer) Dim sSQL As String Set pCnn = […]

使用范围时Excel VBA错误1004

我在VBA工作,我需要做一个512X512(cellsXcells)的正方形大小。 广场假设与细胞的边界。 我做了dynamic的大小,所以用户可以插入他想要的大小(最大为512)。 现在我尝试了很less的技术来做到上面的事情,但总是因为错误1004的运行时间而失败。 Sub printGrid(gridSize) Range(Cells(1, 1), Cells(gridSize, gridSize)).Select With Selection.Borders(xlEdgeLeft) .LineStyle = xlContinuous .Weight = xlThick End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThick End With With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThick End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous .Weight = xlThick End With With Selection.Borders(xlEdgeRight) .LineStyle = xlContinuous […]

EXCEL 2010运行时错误'50290'对象'_Worksheet'的方法“_Evaluate”失败

然后我双击数据validation的单元格,然后尝试从下拉列表中select我得到错误运行时错误运行时错误“50290”。 对象“工作表”的方法“_Evaluate”失败 Private Sub Worksheet_Change(ByVal Target As Range) Select Case Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row Case Is < 5 LastRow = 5: CountRow = 0: R = 1 Case Is > 5 LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row: CountRow = LastRow – 4: R = 0 Case 5 LastRow = Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row: CountRow = […]

从一张纸复印到另一张时发生运行时错误

我有下面列出的代码,我想复制包含在if语句中的规则的每一行,并将其粘贴到第二个工作表中。 这是我的: Sub Button1_Click() Dim i As Long, j As Long Dim mainworkBook As Workbook Set mainworkBook = ActiveWorkbook Lastrow = Cells(Rows.Count, "Y").End(xlUp).Row j = 1 For i = 5 To Lastrow If (IsEmpty(Range(Cells(i, 2), Cells(i, 2)))) Then If IsNumeric(Range(Cells(i, 25), Cells(i, 25))) Then Range(Cells(i, 1), Cells(i, 1)).Value = "T" Range(Cells(i, 2), Cells(i, 24)).Value = […]

我一直在Excel VBA中收到#value错误

所以我在VBA for Excel中写了一个快速函数,但每次我调用它时,都会给我一个#value错误。 我不知道我做错了什么。 谁能帮忙? Function h(UA, k, A, Af_At, Delta, l) h1 = 0 m = (2 * h1 / k / Delta) ^ 0.5 ml = m * l Nf = WorksheetFunction.Tanh(ml) No = 1 – Af_At * (1 – Nf / ml) UA1 = h1 * A * No / 2 While […]

根据VBA excel中的search结果,查找值的重复值并更改其他单元格的值

我有一个Excel文件,我想写一个VBA代码。 我想检查特定列中的值,如果某个值有多个出现次数,则其他列中所有相关行的值将被总结并设置为自己。 让我给你举个例子。 我有一个这样的工作表: 我检查栏"C" 。 在第444 + 43434 + 43434 = 87312行中有3个出现0我总结了"B1" , "B4"和"B6" ,这将是444 + 43434 + 43434 = 87312 ,并将这个总和设置为相同的列,即所有"B1" , "B4"和"B6"单元格的值将为87312 。 我find了一个代码,用于查找所有有价值的事件,并且改变它适合我的问题。 但我找不到另一列的相关单元格。 这是我使用的代码: Sub FindRepetitions() Dim ws As Worksheet Dim rng As Range Dim lastRow As Long Dim SearchRange As Range Dim FindWhat As Variant Dim FoundCells As Range […]

无法使用VB代码从其他网站的Excel中导入数据

我尝试从一个网站使用VB代码导入Excel中的一些数据。 在testing过程中,首先在login部分得到了错误438,这是由尊敬的Siddharth Rout先生(再次感谢)通过我先前的问题运行时错误438纠正的, 同时使用VBA从安全网站导入excel中的数据 。 现在我在下面的部分面对错误438,无法导入数据/ Excel表保持空白。 'get the table based on the table's id Set ieDoc = ieApp.Document Set ieTable = ieDoc.all.Item("report-table") 'copy the tables html to the clipboard and paste to the sheet If Not ieTable Is Nothing Then Set clip = New DataObject clip.SetText "<html>" & ieTable.outerHTML & "</html>" clip.PutInClipboard Sheet1.Select Sheet1.Range("A1").Select […]