Thanks to everyone for your replies. Once I had UBound and LBound it was easy. For reference, here is the (much less elegant) solution I had originally come up with using error handlers. I worked, but ugh.
===========================
Private Function HdrChk(ByVal ShtName As String, ByVal ColHdrs As Variant) As Boolean
Dim i, d As Long
'set an offset value in case lbound <> 1
d = 1 - LBound(ColHdrs)
'fill top row with header labels
For i = LBound(ColHdrs) To UBound(ColHdrs)
Worksheets(ShtName).Cells(1, i + d).Value = ColHdrs(i)
Next i
'return true. This boolean is currently a programming
'artifact, but it has been kept in case some error
'handling is desired.
HdrChk = True
Exit Function
End Function
Private Function XHdrChkX(ByVal ShtName As String, ByVal ColHdrs As Variant) As Boolean
Dim i As Long
On Error GoTo ErrHdlr
i = 1
Do Until True
Worksheets(ShtName).Cells(1, i).Value = ColHdrs(i)
i = i + 1
Loop
LoopExit:
XHdrChkX = True
Exit Function
ErrHdlr:
If Err = 9 Then
GoTo LoopExit
Else
XHdrChkX = False
Exit Function
End If
End Function
Per Jessen wrote:
Hi CraigIf you want to determine how many elements that has been loaded into
22-Nov-09
Hi Crai
If you want to determine how many elements that has been loaded into you
array, I think this is what you need
Dim HRColHdrs(3) As Varian
Private Sub HdrChk(ByVal ShtName As String, ByRef ColHdrs As Variant
Dim i As Long, n As Lon
For i = LBound(ColHdrs) To UBound(ColHdrs
If ColHdrs(i) <> "" The
n = n +
End I
Nex
Debug.Print n & " elements are in this array
End Su
Regards
Pe
"Craig Remillard" skrev i meddelelsen
Previous Posts In This Thread:
EggHeadCafe - Software Developer Portal of Choice
SQL Injection - SQL Server Convert EXEC To Avoid Attacks
http://www.eggheadcafe.com/tutorials...sql-serve.aspx