Results 1 to 10 of 10

allowing for different string lengths in message box

Threaded View

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,287

    allowing for different string lengths in message box

    The following code gives a warning message but the different string lengths of the registration numbers is offsetting longer values

    Sub a1()
    Dim LR As Long, i As Long, msg As String
    With Sheets("TRUCK SERVICE")
    
        Dim rCell As Range
        Dim rRng As Range
        Set rRng = Sheet1.Range("B3:b56")
    
        'For Each rCell In rRng.Cells
            'rCell.NumberFormat = "@"
            'rCell.Value = myFormat(rCell.Value)
        'Next rCell
        LR = .Range("l" & Rows.Count).End(xlUp).Row
        For i = 2 To LR
            If IsDate(.Range("l" & i)) Then
                 If .Range("l" & i).Value - Date < 30 Then
                     msg = msg & vbTab & .Range("B" & i).Value & vbTab & "CVRT Expiry" & vbTab & Format(.Range("l" & i).Value, "dd/mm/yyyy") & vbCrLf
                 End If
            End If
        Next i
    End With
    If msg <> "" Then MsgBox prompt:=Left(msg, Len(msg) - 1), Title:="CVRT Expiry Warning", Buttons:=vbExclamation
    End Sub
    Public Function myFormat(str As String) As String
        myFormat = Format(str, "!" & String(9, "@"))
    End Function
    I've tried quite a few methods, including the above function, but cant find the solution. Anyone any ideas?? Appreciated as its annoying
    Attached Images Attached Images
    Last edited by nigelog; 04-19-2018 at 04:05 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Extract String After and Before Certain Characters of Variable Lengths
    By ex245 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-05-2017, 09:59 PM
  2. VBA to parse a text string containing three fields of different lengths
    By rupsidhu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2015, 09:01 PM
  3. Variable VBA Array Lengths, insert into cell as string
    By Speshul in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-03-2014, 04:26 PM
  4. [SOLVED] Formula to find a match with different string lengths
    By mcranda in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 08-09-2013, 04:34 PM
  5. Trim/parse from right within cell - string lengths different
    By oprpjm in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-26-2013, 03:55 PM
  6. Replies: 3
    Last Post: 05-09-2012, 11:36 AM
  7. CONCATENATE Spacing Issue Due to String Lengths
    By ffmariners in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-17-2008, 02:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1