VBA范围公式问题(LEN,RIGHT和LEFT) [英] VBA range.formula issue (LEN, RIGHT & LEFT)
本文介绍了VBA范围公式问题(LEN,RIGHT和LEFT)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图做一个VBA代码来完成两件事,如下所示:
I'm trying to do a VBA code to accomplish 2 things as follows:
使用公式LEN(A1)
计算单元格A1
上有多少个字符,最后一行计算一个字符,我试图在单元格J1
上具有公式RIGHT(LEFT(A1;Q1-2);6)
Count how many characters there is on cell A1
, using the formula LEN(A1)
and one the last line, I'm trying to have the formula RIGHT(LEFT(A1;Q1-2);6)
on cell J1
到目前为止,请遵循我的VBA代码:
Please follow down my VBA code so far:
LR = Cells(Rows.Count, "A").End(xlUp).Row
For i = 1 To LR
cel = "A" & i
cel2 = "P" & i
cel3 = "Q" & i
Range("P" & i).Formula = "=LEN(" & cel & ")"
Range("J" & i).Formula = "=RIGHT(LEFT(" & cel & "," & cel3 & "-" & 2 & ")," & 6 & ")"
Next i
似乎缺少了一些愚蠢的东西,但是,到目前为止,我仍无法解决
It seems something silly what is missing, however, I couldnt manage to solve it so far
预先感谢
推荐答案
您缺少权利以及其他一些东西
You’re missing a Right, and some other things
Range("J" & i).Formula = "=RIGHT(LEFT(" & cel & "," & cel3 & "-2), 6)"
这篇关于VBA范围公式问题(LEN,RIGHT和LEFT)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文