簡體   English   中英

在宏中應用excel公式時遇到錯誤

[英]Facing Error while applying excel formula in Macro

我在excel的J列中有以下類型的值

<a href="http://twitter.com" rel="nofollow">Twitter Web Client</a>

而且,我用過這個公式

=RIGHT(LEFT(J2,LEN(J2)-4),LEN(LEFT(J2,LEN(J2)-4))FIND(">",LEFT(J2,LEN(J2)-4),2))

獲取此值“Twitter Web Client。

當我嘗試使用以下代碼為此應用宏時,沒有獲得價值。 還可以通過在引用“J”列的“Q”列的整個范圍內應用公式來幫助我編寫代碼

Sub Enter_Formula()

    Range("Q2").Formula = "=RIGHT(LEFT(J2,LEN(J2)-4),LEN(LEFT(J2,LEN(J2)-4))-FIND(" > ",LEFT(J2,LEN(J2)-4),2))"

End Sub

你可以試試這樣的

LastRow = ActiveSheet.UsedRange.Rows.Count
MsgBox LastRow 'This would give the User range value to be used to enter the formulaa in all the rows
Range("Q2:Q" & LastRow).Formula = "=LEFT(RIGHT(RC[-7],LEN(RC[-7])-FIND("">"",RC[-7],2)),LEN(RIGHT(RC[-7],LEN(RC[-7])-FIND("">"",RC[-7],2)))-4)"

結果集將是“Twitter Web Client”文本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM