开发者

How to paste formula from visual basic to excel In relative

开发者 https://www.devze.com 2022-12-30 10:15 出处:网络
In visual basic code works as below MyWorksheet.Range(\"A1:D1\").Formula = \"A1B2\" In excel it shows in

In visual basic code works as below

MyWorksheet.Range("A1:D1").Formula = "A1B2"

In excel it shows in

 A1 as A1B2
 B1 as A1B2
 C1 as A1B2
 D1 as A1B2 

what i want do

 A1 as A1B2
 B1 as A1B3
 C1 as A2B4开发者_如何学Python
 D1 as A2B5

Thanks in Advance


In VBA it is:

For colNumber = 1 To 4
   Row.Cells(1, clNumber).Formula = "A" & colNumber & "B" & colNumber + 1
Next clNumber

In .Net it is:

for(int colNumber = 1; colNumber<=4; colNumber++)
   {
    MyWorksheet.Row.Cells(1, colNumber).Formula = "A" + colNumber + "B" + (colNumber + 1)
   }
0

精彩评论

暂无评论...
验证码 换一张
取 消