Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, that was both the function that I ended up using (HdrChk), and the original function with error handler loop escape (XHdrChkX). The latter now goes to the graveyard!
Craig Remillard wrote: Solution taken 23-Nov-09 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 Previous Posts In This Thread: EggHeadCafe - Software Developer Portal of Choice Map Stored Procedure Output To Class Properties http://www.eggheadcafe.com/tutorials...dure-outp.aspx |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Assign Range passed to fuction to an array | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
Array problem: Key words-Variant Array, single-element, type mismatch error | Excel Programming | |||
ReDim Object array as parameter of Variant array | Excel Programming | |||
variant array containing cel adresses convert to actual ranges-array | Excel Programming |