How to edit cell value in VB.net - Using .Interop.

2019-07-28 01:23发布

This is a simple question. I have this code:

 CurrentRow = 3
 MyColumn = 2
 CurrentCell = (CurrentRow & "," & MyColumn)
 WorkingSheet.Cells(CurrentCell).value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)

I thought that this would place the data on the 'WorkingSheet' in the position "B3" but it places the data in the cell "AF1".

Why is this?

Thanks,

Josh

1条回答
相关推荐>>
2楼-- · 2019-07-28 01:47

Cell is not expected to be used as you are using it; you have to input the row and column indices (as integers) separated by a comma. Thus the right code is:

WorkingSheet.Cells(CurrentRow, MyColumn).Value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)

Another alternative you have is using Range. Example:

WorkingSheet.Range("B3").Value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)
查看更多
登录 后发表回答