|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Column Letter
How can I extract the column letter of the last column in use?
|
|
#2
|
||||
|
||||
|
you can try the following code to extract last row, last column ... however, it returns the column as a number, not letter:
Code:
Set xl_App = CreateObject("Excel.Application")
xl_App.Visible = false
Set xl_Sheet = xl_App.ActiveSheet
With xl_Sheet.Range("A1").SpecialCells(11)
lastRow = .Row
lastCol = .Column
End With
__________________
Come JOIN the party!!! Quote of the Month: Retirement: Because you've given so much of yourself to the company that you don't have anything left we can use. Questions to Ponder: What do you do when you see an endangered animal eating an endangered plant? iif([sarcasm]=true,iif([you have to ask]=true,"didn't work","ha ha ha"),"not sarcasm") copyright© 2008 sbenj69 |
|
#3
|
|||
|
|||
|
I managed it on my own. It may be a little "over the top" and there is probably a much easier way to do it, but as long as it works its okay with me
![]() '---- Column Number to Letter ------ usedColumnsCount = objExcel.sheets(1).UsedRange.Columns.Count if usedColumnsCount=1 Then lastColumnsLetter="A" else if usedColumnsCount=2 Then lastColumnsLetter="B" else if usedColumnsCount=3 Then lastColumnsLetter="C" else if usedColumnsCount=4 Then lastColumnsLetter="D" else if usedColumnsCount=5 Then lastColumnsLetter="E" else if usedColumnsCount=6 Then lastColumnsLetter="F" else if usedColumnsCount=7 Then lastColumnsLetter="G" else if usedColumnsCount=8 Then lastColumnsLetter="H" else if usedColumnsCount=9 Then lastColumnsLetter="I" else if usedColumnsCount=10 Then lastColumnsLetter="J" else if usedColumnsCount=11 Then lastColumnsLetter="K" else if usedColumnsCount=12 Then lastColumnsLetter="L" else if usedColumnsCount=13 Then lastColumnsLetter="M" else if usedColumnsCount=14 Then lastColumnsLetter="N" else if usedColumnsCount=15 Then lastColumnsLetter="O" else if usedColumnsCount=16 Then lastColumnsLetter="P" else if usedColumnsCount=17 Then lastColumnsLetter="Q" else if usedColumnsCount=18 Then lastColumnsLetter="R" else if usedColumnsCount=19 Then lastColumnsLetter="S" else if usedColumnsCount=20 Then lastColumnsLetter="T" else if usedColumnsCount=21 Then lastColumnsLetter="U" else if usedColumnsCount=22 Then lastColumnsLetter="V" else if usedColumnsCount=23 Then lastColumnsLetter="W" else if usedColumnsCount=24 Then lastColumnsLetter="X" else if usedColumnsCount=25 Then lastColumnsLetter="Y" else if usedColumnsCount=26 Then lastColumnsLetter="Z" end if |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Column Letter |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|