Excel Macro Just need to go next ROW if the value is not Numeric.

Gomes1985

New Member
Joined
Jun 20, 2016
Messages
32
This code has some syntax error but its generic I cant understand. Says For with no Next I have got an next in code it as I am new at this how can I Skip to next row if the row does not contain a number?

For Each Nextcell In Range(InitialRow)
If Not IsNumeric(Nextcell) Then
IsNotNumber = True
Sheets("GAMMING").Range("B" & InitialRow).Select
InitialRow = InitialRow + 1
End If
Next Nextcell

Any help would be great
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Gomes.

You need to tell us what your wanting to do and we will write you a script.
 
Upvote 0
What I currently doing it I have Excel sheet I am reading 1 line at a time.

The Column A contains Integers and Strings. I just need to skip to the next line if the code comes across any String only in Column A.

hope that makes more sense now?
 
Upvote 0
Since you really did not say what your wanting to do this may help

If IsNumeric(Cells(i, 1)) = True Then
 
Upvote 0
The table is

SEQaccbsb
11234567
bas456789
21234567
314778999


<colgroup><col width="64" style="width:48pt"> <col width="64" span="2" style="width:48pt"> </colgroup><tbody>
</tbody>
Below is the code


Private Sub CommandButton1_Click()
Dim InitialRow As Integer
InitialRow = 2
Set BaseSheet = ThisWorkbook.Sheets("sheet2")

FinalRow = BaseSheet.Cells(BaseSheet.Rows.Count, "A").End(xlUp).Row 'This gives the number of data in the column "B"
For RowCounter = 2 To FinalRow ' The loop you wanted



If RowCounter = FinalRow Then
MsgBox ("The End")
End
End If



If IsNumeric(Range("A2")) = True Then
Range("D2") = "A1 is a number"
Else
Range("D2") = "A1 is not number"

End If

Sheets("Sheet2").Range("A" & InitialRow).Select
InitialRow = InitialRow + 1

Next

End Sub

I have done a bit of changes to previous code just dont know why output is not changing in each row
 
Upvote 0
Hi Gomes1985,

Try this:

Code:
Option Explicit
Sub Macro2()

    Dim lngMyRow As Long
    Dim lngLastRow As Long
    Dim wsSource As Worksheet
    
    Application.ScreenUpdating = False
    
    Set wsSource = Sheets("Sheet2")
    
    lngLastRow = wsSource.Cells(Rows.Count, "A").End(xlUp).Row
    
    For lngMyRow = 2 To lngLastRow
        If IsNumeric(wsSource.Range("A" & lngMyRow)) = True Then
            wsSource.Range("D" & lngMyRow).Value = "A" & lngMyRow & " is a number"
        Else
            wsSource.Range("D" & lngMyRow).Value = "A" & lngMyRow & " is not a number"
        End If
    Next lngMyRow
    
    Application.ScreenUpdating = True

End Sub

Regards,

Robert
 
Upvote 0
Sorry just side Question on this same code.

Instead of getting a output on Column D. If I just read whats on Column A and NOT provide an output but go to nextline

How would I do it?
 
Upvote 0
You just want the script to just check and then do nothing but go to next row then use this script.

Code:
Option Explicit
Sub Macro2()

    Dim lngMyRow As Long
    Dim lngLastRow As Long
    Dim wsSource As Worksheet
    
    Application.ScreenUpdating = False
    
    Set wsSource = Sheets("Sheet2")
    
    lngLastRow = wsSource.Cells(Rows.Count, "A").End(xlUp).Row
    
    For lngMyRow = 2 To lngLastRow
        If IsNumeric(wsSource.Range("A" & lngMyRow)) = True Then
            
        Else
            
        End If
    Next lngMyRow
    
    Application.ScreenUpdating = True

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,930
Members
449,195
Latest member
Stevenciu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top