尝试执行以下代码时,出现错误“运行时错误'1004':应用程序定义的错误或对象定义的错误”。
如果它们为空,我正在尝试将此公式放入多个单元格中:
<ul>
<li>
<a href=#popup1>
<img class="new-tracks__image" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/1774776/new.jpg"></a>
<div id="popup1" class="overlay">
<div class="popup">
<h2>Jerry Craft - <em>"New Kid"</em></h2>
<iframe src="https://open.spotify.com/embed/album/2yFC1YqdyPHnpCGJubdGaK" width="300" height="80" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
<div class="overlay-text">
<p>The three Greystone kids always raced each other home when they got off the school bus, and Finn always won.</p>
<p>It wasn’t because he was the fastest.</p>
<p>Even he knew that his older brother and sister, Chess and Emma, let him win so he could make a grand entrance.</p>
<p>Today he burst into the house calling out, “Mom! We’re home! It’s time to come and adore us!”</p>
<p>“Adore” had been on his second-grade spelling list two weeks ago, and it had been a great discovery for him. So that was what it was called, the way he had felt his entire life.</p>
<p>Emma, who was in fourth grade, dropped her backpack on the rug beside him and kicked off her red sneakers. They flipped up and landed on top of the backpack—someday, Finn vowed, he would get Emma to teach him that trick.</p>
<p>“Twenty-three,” Emma said. There was no telling what she might have been counting. Finn hoped it was a prediction of how many chocolate chips would be in every cookie Mom was probably baking for them right now, for their after-school snack.</p>
<p>Finn sniffed. The house did not smell like cookies.</p>
<p>Oh well. Mom worked from home, designing websites, and sometimes she lost track of time. If today was more of a Goldfish-crackers-and-apple-slices kind of day, that was okay with Finn. He liked those, too.</p>
<p>“Mom!” he called again. “Your afternoon-break entertainment has arrived!”</p>
<p>“She’s in the kitchen,” Chess said, hanging his own backpack on the hook where it belonged. “Can’t you hear?”</p>
<p>“That would mean Finn had to listen for once, instead of talking,” Emma said, rubbing Finn’s head fondly and making his messy brown hair even messier. Finn knew she didn’t mean it as an insult. He was pretty sure Emma liked talking as much as
he did.</p>
<a class="close" href="#">×</a>
</div>
</div>
</li>
</ul>
“ A1”中的1为代表行#的循环定义变量r的输出,列字母为静态。
=BDP(B1 & " Muni", "CPN")
我可以将Sub Add_BBG_Coupons()
Dim r As Long
Dim LastRow As Long
Dim BDP1 As String
Dim BDP2 As String
Dim strQuote As String
wSheets = Array("ACTHXSortNeg", "ACTHXSortPos", "ISHAXSortPos", "ISHAXSortNeg")
For I = LBound(wSheets) To UBound(wSheets)
With Worksheets(wSheets(I)).Activate
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For r = LastRow To 1 Step -1
If IsEmpty(Cells(r, 4)) = True Then
Cells(r, 4).Select
ActiveCell.Formula = "=BDP(B" & r & " Muni"",""CPN"")"
End If
Next r
End With
Next I
End Sub
插入单元格,但是当我在此处使用双引号尝试获取=BDP(A1 & Muni,CPN)
时,会收到上述错误。
我尝试将变量设置为=BDP(B1 & " Muni", "CPN")
以及Chr(34)
并进行串联,但是随后出现对象定义的错误。
答案 0 :(得分:0)
Sub testsub()
r = " & "
With Range("a1")
.Formula = "=BDP(B" & r & Chr(34) & " Muni" & Chr(34) & ", " & Chr(34) & "CPN" & Chr(34) & ")"
End With
End Sub
这应该有效。您无需合并chr(),而是将其用作变量,其名称末尾会有大量的变体。因此,使用"sometext " & chr(34) & " somemoretext"
将其添加到您的公式中,它将打印为sometext " somemoretext