Allow alpha numeric values instead of isnumeric

0 votes

I have the following code for calling a function and duplicating the above line's borders and orientation. How can I change the code so that I may enter alpha numeric values in that cell as this only accepts numeric values?

Below is the code

Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B:B")) Is Nothing Then
        If IsNumeric(Target.Value) Then ' Check if cell contains a numeric value
            If Target.Value <> "" Then
            Range("A" & Target.Row).Formula = "=IF(B" & Target.Row & "<>"""",ROW()-ROW($A$15)+1,"""")"
            ' Copy border, border color and orientation from row above
            With Range("A" & Target.Row & ":H" & Target.Row)
                .Borders.LineStyle = .Offset(-1, 0).Borders.LineStyle
                .Borders.Color = .Offset(-1, 0).Borders.Color
                .Orientation = .Offset(-1, 0).Orientation
            End With
        Else
            ' Check if entire row in column B is empty
            If WorksheetFunction.CountA(Range("B" & Target.Row & ":H" & Target.Row)) = 0 Then
                ' Delete entire row
                Rows(Target.Row).Delete
            Else
                ' Clear contents of column A to H for the row where value was deleted in column B
                Range("A" & Target.Row & ":H" & Target.Row).ClearContents
            End If
        End If
    End If
End If
End Sub
Feb 18, 2023 in Others by Kithuzzz
• 38,000 points
477 views

1 answer to this question.

0 votes

Here's a small Function you could add to your code, to give it IsAlphaNumeric functionality.

Function IsAlphaNumeric(t) as Boolean
    Dim i as Long
    IsAlphaNumeric = True
    For i = 1 To Len(t)
        If Not (Mid(t, i, 1) Like "[A-z0-9]") Then
            IsAlphaNumeric = False
            Exit For
        End If
    Next
End Function

You can use it like this:

If IsAlphaNumeric(Target.Value) Then ' Check if cell contains alpha-numeric value
answered Feb 18, 2023 by narikkadan
• 63,600 points

Related Questions In Others

0 votes
1 answer
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

We can use expressions as well in ...READ MORE

answered May 31, 2022 in Others by Sohail
• 3,040 points
689 views
0 votes
1 answer

Ordering by the order of values in a SQL IN() clause

Use MySQL FIND_IN_SET function: SELECT * ...READ MORE

answered Jun 6, 2022 in Others by nisha
• 2,210 points
693 views
0 votes
1 answer

How to add Conditional Formatting in Excel for a Range of Values

Three distinct rules are required, one for ...READ MORE

answered Oct 24, 2022 in Others by narikkadan
• 63,600 points
1,164 views
0 votes
1 answer

Retrieve epay.info Balance with VBA and Excel

This code should log you in, provided ...READ MORE

answered Sep 5, 2018 in Blockchain by digger
• 26,740 points
1,260 views
0 votes
1 answer

How to load file to Excel Power query from SFTP site

Currently, I don't think there is a ...READ MORE

answered Dec 3, 2018 in Power BI by Upasana
• 8,620 points
3,698 views
0 votes
1 answer

Using VBA Excel to create a gramatically correct list

The Excel AND function is a logical ...READ MORE

answered Feb 9, 2022 in Others by gaurav
• 23,260 points
979 views
0 votes
2 answers

How to copy a formula horizontally within a table using Excel VBA?

Hi so basically, create an adjacent column ...READ MORE

answered Feb 16, 2022 in Others by Edureka
• 13,690 points
1,091 views
0 votes
1 answer

how to show the <meta> values of yoast seo with some function?

check this folder : wordpress-seo\src\presenters\open-graph you can ...READ MORE

answered Feb 10, 2022 in Others by narikkadan
• 63,600 points
624 views
0 votes
1 answer

Removing duplicates from Excel rows by adding values of some columns

Copy the first three columns to another ...READ MORE

answered Sep 23, 2022 in Others by narikkadan
• 63,600 points
933 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP