Results 1 to 11 of 11

Seeking assistance with ths code

Threaded View

kmakjop Seeking assistance with ths... 10-04-2012, 02:02 PM
Bishonen Re: Seeking assistance with... 10-04-2012, 02:13 PM
kmakjop Re: Seeking assistance with... 10-04-2012, 03:16 PM
Bishonen Re: Seeking assistance with... 10-04-2012, 03:31 PM
mike7952 Re: Seeking assistance with... 10-04-2012, 03:29 PM
kmakjop Re: Seeking assistance with... 10-04-2012, 04:41 PM
kmakjop Re: Seeking assistance with... 10-04-2012, 05:05 PM
jeffreybrown Re: Seeking assistance with... 10-04-2012, 05:08 PM
mike7952 Re: Seeking assistance with... 10-04-2012, 05:09 PM
kmakjop Re: Seeking assistance with... 10-08-2012, 03:55 PM
jeffreybrown Re: Seeking assistance with... 10-08-2012, 04:47 PM
  1. #1
    Forum Contributor
    Join Date
    09-15-2012
    Location
    Jamaica
    MS-Off Ver
    Microsoft 365
    Posts
    244

    Seeking assistance with ths code

    I am new to vba and i am trying to write a code to validate the "A" column. if the cell character length = 16 then add the letter "C" to the cell.
    if the cell not <> 9 and it is <> 16 then delete the info entered in the cell. I would like the cell that was deleted to still be selected after the validation of the cell is done (this part is optional though). The primary thing is to validate the cell. I got both codes to work but not at the same time. if it captures one condition it misses out the other.

    Kindly assist thank you.


    below is a sample of the code:

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Worksheets("Sheet1").Range("a8:a") <> "" Then
    If Len(Target.Value) = 16 Then
    Target.Value = "C" & Target.Value
    MsgBox ("test")
    End If
    End If
    If Worksheets("Sheet1").Range("a8:a") <> "" Then
    If Len(Target.Value) <> 9 And Len(Target.Value) <> 16 Then
    MsgBox ("test again")
    Target.Value = Left(Target.Value, 0)
    End If
    End If

    End Sub
    Last edited by kmakjop; 10-04-2012 at 02:07 PM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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