简体   繁体   English

在宏中应用excel公式时遇到错误

[英]Facing Error while applying excel formula in Macro

I have the below type of values in column J in excel我在excel的J列中有以下类型的值

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

and, I have used this formula而且,我用过这个公式

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

to get this value "Twitter Web Client.获取此值“Twitter Web Client。

When I tried to apply Macro for this using below code in not getting value.当我尝试使用以下代码为此应用宏时,没有获得价值。 Also help me in code by applying formula in the entire range of 'Q' column referencing the 'J' column还可以通过在引用“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

You could try something like this你可以试试这样的

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)"

The result set would be "Twitter Web Client" text.结果集将是“Twitter Web Client”文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM