-
Nov 9th, 2020, 09:13 AM
#1
Thread Starter
Banned
Convert Syntax from VBA to VB.Net
Dear All
We are moving from VBA to VB.net in our company and I converted many syntaxes from VBA to VB.net except some, this is one of them but I tried as you will see below:
BBS is the Sheet name in VBA
ws is the sheet name in VB.net
The VBA Syntax is :
Code:
rgnInp =INDEX(BBS!$D:$D, ROW(BBS!$D$11)+1):INDEX(BBS!$E:$E, MATCH(conBig, BBS!$D:$D))
conBig = 9.999999999
I Converted it to VB.Net as below:
Code:
rgnInp = xl.WorksheetFunction.Index(ws.Range("D", "D"), ("D11") + 1) : xl.WorksheetFunction.Index(ws.Range("E", "E"), xl.WorksheetFunction.Match(conBig, ws.Range("D", "D")))
I can not find what should replace ROW in VB.net
When the program runs, it gives unhandled Error Exception
Appreciate your help
Thanks, Regards
Moheb Labib
-
Nov 9th, 2020, 10:51 AM
#2
Re: Convert Syntax from VBA to VB.Net
That's Excel, not VBA
You should ask in the Office Development forum. I'll ask a moderator to move this question...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Nov 9th, 2020, 10:57 AM
#3
Re: Convert Syntax from VBA to VB.Net
According to the VBA documents, ROW returns the first row number of the selected reference.
In this case, your selected range is D11. But if you're hard-coding that cell and adding 1 to it, why not just specify 12:
Code:
... xl.WorksheetFunction.Index(ws.Range("D", "D"), 12) ...
In fact, it looks like you just want the value from D12. Why not remove the function and just get the value:
Code:
Dim rgnInp = xl.Range("D12").Value
-
Nov 9th, 2020, 10:58 AM
#4
Re: Convert Syntax from VBA to VB.Net
It's not plain Excel, and the goal is .NET, so it seems like a pretty clear cross-over question that could work just as well in either location.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|