Consulting

Results 1 to 7 of 7

Thread: Truncate Data in Excel VBA to prompt Pass or Fail

  1. #1
    VBAX Regular
    Joined
    Oct 2016
    Posts
    11
    Location

    Post Truncate Data in Excel VBA to prompt Pass or Fail

    Hi, I am newbie to Excel VBA
    I am need help on VBA to displaying Pass or Fail result in the txtResult box in "Form" tab. And the result should refer to "Data" tab on D column. As there contained excel formula to truncated the entered serial number & check the value in "Ref" tab. Hereby, is there any more simple way to run the formula in VBA? Million Thanks,
    Attached Files Attached Files

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Your code seems to be writing whatever is entered onto the form onto the Data tab, but your request seems to be asking to get data from that tab? Which is it? Give an example of the form input and t he result that you want to see.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Oct 2016
    Posts
    11
    Location

    Post

    Quote Originally Posted by Bob Phillips View Post
    Your code seems to be writing whatever is entered onto the form onto the Data tab, but your request seems to be asking to get data from that tab? Which is it? Give an example of the form input and t he result that you want to see.
    Thanks for fast reply.
    The Serial number input should be truncated the first 5 digits from left after the entry (After click "Check" button).
    Example data: 794901020
    After truncated became 79490
    This value will use to check not exceed a max & min given Spec (in different sheet). And the given can be change by manually time to time.
    Min Value:- 79490
    Max Value:- 79989

    Expected output Value fall in between Min & Max value. It will shown pass as below image. If value out of this criteria. Result will prompt Fail.

    Pass Image
    Pass Image.JPG
    Fail Image
    Fail Image.JPG

    Thanks for your valuable time.

  4. #4
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Dim TruncNo As Long
    Dim Passes As Boolean
    TruncNo = CLng(Lext(txtSerial, 5))
    Passes = (TruncNo >= MinNo And TruncNo <= MaxNo)
    Your current Private Sub cmdCheck_Click() code does nothing worthwhile.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  5. #5
    VBAX Regular
    Joined
    Oct 2016
    Posts
    11
    Location
    Quote Originally Posted by SamT View Post
    Dim TruncNo As Long
    Dim Passes As Boolean
    TruncNo = CLng(Lext(txtSerial, 5))
    Passes = (TruncNo >= MinNo And TruncNo <= MaxNo)
    Your current Private Sub cmdCheck_Click() code does nothing worthwhile.

    Thanks, SamT
    However, I am don't know how to use the function of Lext. It is not working in module.

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Quote Originally Posted by VBWEE View Post
    However, I am don't know how to use the function of Lext. It is not working in module.
    That should be Left.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Quote Originally Posted by Bob Phillips View Post
    That should be Left.
    Thanks. My Keyboard doesn't know how to type
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

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