Created
March 16, 2012 05:29
-
-
Save nobrinskii/2048655 to your computer and use it in GitHub Desktop.
[vba/excel] 指定された行の、入力された最終列番号を取得する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'------------------------------------------------------------------------------- | |
'指定された行の、入力された最終列番号を取得する | |
'------------------------------------------------------------------------------- | |
'【引数】対象シート、対象の行番号 | |
'【戻り値】列番号 | |
'【備考】シートの右端から左方向に検索して、最初に値が入ったセルの列番号を返す。 | |
Private Function GetLastColNumber(shtTarget As Worksheet, lngRow As Long) As Integer | |
Dim intMaxCol As Integer | |
Dim intLastCol As Integer | |
With shtTarget | |
intMaxCol = .Cells().Columns.Count | |
intLastCol = .Cells(lngRow, intMaxCol).End(xlToLeft).Column | |
End With | |
GetLastColNumber = intLastCol | |
End Function |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment