Function PadR(lStr As String, lLength As Long, lPadChar As String) As String Dim lsPad As String, lsTmp As String Dim llen As Long If lLength < 0 Then PadR = "" Exit Function End If ' must pass a character value; if empty string use default " " ' you could make the lPadChar Optional but then you have to check ' datatype as well If lPadChar = "" Then lsPad = " " Else lsPad = lPadChar End If If Len(Trim(lStr)) >= lLength Then PadR = Left(lStr, lLength) Exit Function End If lsTmp = Trim(lStr) llen = Len(lsTmp) PadR = lsTmp & String(lLength - llen, lsPad) End Function