visual studio vb - Convert cell (Excel) address from “C15” to Row = 15 and Column = 3
up vote
0
down vote
favorite
I have a simple application that is required to access Excel files, inject some data into selected cells, and retrieve calculated results from yet another cell.
All cells references are received in the form <letter(s)><number>
(e.g. G35).
The problem is that the way to access the cells within Visual Studio (as far as I could find) is by using Row and Column values.
Is there a simple way to convert letter-number format to Row-Column format? Or, alternatively, access cells using the letter-number format.
excel vb.net reference
add a comment |
up vote
0
down vote
favorite
I have a simple application that is required to access Excel files, inject some data into selected cells, and retrieve calculated results from yet another cell.
All cells references are received in the form <letter(s)><number>
(e.g. G35).
The problem is that the way to access the cells within Visual Studio (as far as I could find) is by using Row and Column values.
Is there a simple way to convert letter-number format to Row-Column format? Or, alternatively, access cells using the letter-number format.
excel vb.net reference
1
If you use theWorksheet.Range
object, you can specify cell(s) by Excel cell references
– SSS
Oct 16 '17 at 6:40
Yes @SSS That's exactly what I found few minutes after posting the question. Wanted to delete the question but you were too quick :-). I'll flag it anyway.
– FDavidov
Oct 16 '17 at 7:02
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have a simple application that is required to access Excel files, inject some data into selected cells, and retrieve calculated results from yet another cell.
All cells references are received in the form <letter(s)><number>
(e.g. G35).
The problem is that the way to access the cells within Visual Studio (as far as I could find) is by using Row and Column values.
Is there a simple way to convert letter-number format to Row-Column format? Or, alternatively, access cells using the letter-number format.
excel vb.net reference
I have a simple application that is required to access Excel files, inject some data into selected cells, and retrieve calculated results from yet another cell.
All cells references are received in the form <letter(s)><number>
(e.g. G35).
The problem is that the way to access the cells within Visual Studio (as far as I could find) is by using Row and Column values.
Is there a simple way to convert letter-number format to Row-Column format? Or, alternatively, access cells using the letter-number format.
excel vb.net reference
excel vb.net reference
edited Nov 22 at 5:17
asked Oct 16 '17 at 6:30
FDavidov
2,31341129
2,31341129
1
If you use theWorksheet.Range
object, you can specify cell(s) by Excel cell references
– SSS
Oct 16 '17 at 6:40
Yes @SSS That's exactly what I found few minutes after posting the question. Wanted to delete the question but you were too quick :-). I'll flag it anyway.
– FDavidov
Oct 16 '17 at 7:02
add a comment |
1
If you use theWorksheet.Range
object, you can specify cell(s) by Excel cell references
– SSS
Oct 16 '17 at 6:40
Yes @SSS That's exactly what I found few minutes after posting the question. Wanted to delete the question but you were too quick :-). I'll flag it anyway.
– FDavidov
Oct 16 '17 at 7:02
1
1
If you use the
Worksheet.Range
object, you can specify cell(s) by Excel cell references– SSS
Oct 16 '17 at 6:40
If you use the
Worksheet.Range
object, you can specify cell(s) by Excel cell references– SSS
Oct 16 '17 at 6:40
Yes @SSS That's exactly what I found few minutes after posting the question. Wanted to delete the question but you were too quick :-). I'll flag it anyway.
– FDavidov
Oct 16 '17 at 7:02
Yes @SSS That's exactly what I found few minutes after posting the question. Wanted to delete the question but you were too quick :-). I'll flag it anyway.
– FDavidov
Oct 16 '17 at 7:02
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
If you use the Worksheet.Range object, you can specify cell(s) by Excel cell references
To convert a 0-based column index to the equivalent column heading, use the following:
Private Function xlCol(ByVal col As Integer) As String
'col -= 1 'Uncomment this line if you are using 1-based column indices
Dim s As String = ""
If col < 0 Or col > 16383 Then
Throw New ArgumentException(String.Format("{0} is an invalid column", col), "col")
End If
If col >= 26 ^ 2 Then
s = Chr(64 + (col 26 26) Mod 26)
End If
If col >= 26 Then
s &= Chr(64 + (col 26) Mod 26)
End If
s &= Chr(65 + (col Mod 26))
Return s
End Function
According to this link, an Excel spreadsheet cannot have more than 16384 columns (column index 16383 or heading XFD).
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you use the Worksheet.Range object, you can specify cell(s) by Excel cell references
To convert a 0-based column index to the equivalent column heading, use the following:
Private Function xlCol(ByVal col As Integer) As String
'col -= 1 'Uncomment this line if you are using 1-based column indices
Dim s As String = ""
If col < 0 Or col > 16383 Then
Throw New ArgumentException(String.Format("{0} is an invalid column", col), "col")
End If
If col >= 26 ^ 2 Then
s = Chr(64 + (col 26 26) Mod 26)
End If
If col >= 26 Then
s &= Chr(64 + (col 26) Mod 26)
End If
s &= Chr(65 + (col Mod 26))
Return s
End Function
According to this link, an Excel spreadsheet cannot have more than 16384 columns (column index 16383 or heading XFD).
add a comment |
up vote
0
down vote
If you use the Worksheet.Range object, you can specify cell(s) by Excel cell references
To convert a 0-based column index to the equivalent column heading, use the following:
Private Function xlCol(ByVal col As Integer) As String
'col -= 1 'Uncomment this line if you are using 1-based column indices
Dim s As String = ""
If col < 0 Or col > 16383 Then
Throw New ArgumentException(String.Format("{0} is an invalid column", col), "col")
End If
If col >= 26 ^ 2 Then
s = Chr(64 + (col 26 26) Mod 26)
End If
If col >= 26 Then
s &= Chr(64 + (col 26) Mod 26)
End If
s &= Chr(65 + (col Mod 26))
Return s
End Function
According to this link, an Excel spreadsheet cannot have more than 16384 columns (column index 16383 or heading XFD).
add a comment |
up vote
0
down vote
up vote
0
down vote
If you use the Worksheet.Range object, you can specify cell(s) by Excel cell references
To convert a 0-based column index to the equivalent column heading, use the following:
Private Function xlCol(ByVal col As Integer) As String
'col -= 1 'Uncomment this line if you are using 1-based column indices
Dim s As String = ""
If col < 0 Or col > 16383 Then
Throw New ArgumentException(String.Format("{0} is an invalid column", col), "col")
End If
If col >= 26 ^ 2 Then
s = Chr(64 + (col 26 26) Mod 26)
End If
If col >= 26 Then
s &= Chr(64 + (col 26) Mod 26)
End If
s &= Chr(65 + (col Mod 26))
Return s
End Function
According to this link, an Excel spreadsheet cannot have more than 16384 columns (column index 16383 or heading XFD).
If you use the Worksheet.Range object, you can specify cell(s) by Excel cell references
To convert a 0-based column index to the equivalent column heading, use the following:
Private Function xlCol(ByVal col As Integer) As String
'col -= 1 'Uncomment this line if you are using 1-based column indices
Dim s As String = ""
If col < 0 Or col > 16383 Then
Throw New ArgumentException(String.Format("{0} is an invalid column", col), "col")
End If
If col >= 26 ^ 2 Then
s = Chr(64 + (col 26 26) Mod 26)
End If
If col >= 26 Then
s &= Chr(64 + (col 26) Mod 26)
End If
s &= Chr(65 + (col Mod 26))
Return s
End Function
According to this link, an Excel spreadsheet cannot have more than 16384 columns (column index 16383 or heading XFD).
edited Oct 16 '17 at 7:23
answered Oct 16 '17 at 7:15
SSS
4,36811336
4,36811336
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f46764166%2fvisual-studio-vb-convert-cell-excel-address-from-c15-to-row-15-and-colum%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
If you use the
Worksheet.Range
object, you can specify cell(s) by Excel cell references– SSS
Oct 16 '17 at 6:40
Yes @SSS That's exactly what I found few minutes after posting the question. Wanted to delete the question but you were too quick :-). I'll flag it anyway.
– FDavidov
Oct 16 '17 at 7:02