вот парочка полезный функций, которые всегда пригодятся.
Код: '******************************************************
'Procedure : SwitchNumToAlpha
'Function : Given Number equivalent Alphabet
'Requires : Number
'Returns : Alphabet
'Created By : Jay Sarsonas 6/21/2010
'******************************************************
Public Function SwitchNumberToAlphabet(inAlphaNumeric As Long) As String
Dim High
Dim Low
High = inAlphaNumeric \ 26
Low = inAlphaNumeric Mod 26
SwitchNumberToAlphabet = ""
If Low = 0 Then
Low = 26
High = High - 1
End If
If (High > 0) Then
SwitchNumberToAlphabet = Chr(Asc("A") + High - 1)
End If
SwitchNumberToAlphabet = SwitchNumberToAlphabet & Chr(Asc("A") + Low - 1)
End Function
'******************************************************
'Procedure: GetMaxDataRows
'Function: Identifies Max Record Rows given
' Worksheet and Range
'Requires: Worksheet and Range
'Returns: None
'Created by Jay Sarsonas 4/19/2010
'******************************************************
Public Function GetMaxDataRows(xSheetName As String, xRange As String) As Long
'Identify Max Used Rows
With Worksheets(xSheetName)
GetMaxDataRows = .Range(xRange & 65534).End(xlUp).Row
End With
End Function
'******************************************************
'Procedure: GetMaxDataColumns
'Function: Identifies Max Record Columns given
' Worksheet and Range
'Requires: Worksheet and Range
'Returns: None
'Created by Jay Sarsonas 8/23/2010
'******************************************************
Public Function GetMaxDataColumns(xSheetName As String, xRange As String) As Long
'Identify Max Used Rows
With Worksheets(xSheetName)
GetMaxDataColumns = .Range("IU1").End(xlToLeft).Column
End With
End Function
Код: '******************************************************
'Procedure : SwitchNumToAlpha
'Function : Given Number equivalent Alphabet
'Requires : Number
'Returns : Alphabet
'Created By : Jay Sarsonas 6/21/2010
'******************************************************
Public Function SwitchNumberToAlphabet(inAlphaNumeric As Long) As String
Dim High
Dim Low
High = inAlphaNumeric \ 26
Low = inAlphaNumeric Mod 26
SwitchNumberToAlphabet = ""
If Low = 0 Then
Low = 26
High = High - 1
End If
If (High > 0) Then
SwitchNumberToAlphabet = Chr(Asc("A") + High - 1)
End If
SwitchNumberToAlphabet = SwitchNumberToAlphabet & Chr(Asc("A") + Low - 1)
End Function
'******************************************************
'Procedure: GetMaxDataRows
'Function: Identifies Max Record Rows given
' Worksheet and Range
'Requires: Worksheet and Range
'Returns: None
'Created by Jay Sarsonas 4/19/2010
'******************************************************
Public Function GetMaxDataRows(xSheetName As String, xRange As String) As Long
'Identify Max Used Rows
With Worksheets(xSheetName)
GetMaxDataRows = .Range(xRange & 65534).End(xlUp).Row
End With
End Function
'******************************************************
'Procedure: GetMaxDataColumns
'Function: Identifies Max Record Columns given
' Worksheet and Range
'Requires: Worksheet and Range
'Returns: None
'Created by Jay Sarsonas 8/23/2010
'******************************************************
Public Function GetMaxDataColumns(xSheetName As String, xRange As String) As Long
'Identify Max Used Rows
With Worksheets(xSheetName)
GetMaxDataColumns = .Range("IU1").End(xlToLeft).Column
End With
End Function