Numeric field

VbaHell

Well-known Member
Joined
Jan 30, 2011
Messages
1,220
Hello all

I hope you can help on this please.

I am using excel 2007 and in column "B" I have data that can be text or numeric or text and numeric. I need some VBA code please that will copy to column "C" only the numeric fields from column "B"
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Code:
Sub Copy_Numeric()
Dim r As Range
Dim LR As Long
Dim i As Long
Application.ScreenUpdating = False
LR = Range("C" & Rows.Count).End(xlUp).Row
For i = 2 To LR
    If IsNumeric(Cells(i, 3)) Then Cells(i, 2) = Cells(i, 3)
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Try

Code:
Sub Test()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    With Range("B" & i)
        If IsNumeric(.Value) Then .Copy Destination:=Range("C" & Rows.Count).End(xlUp).Offset(1)
    End With
Next i
End Sub
 
Upvote 0
This code works well but the only problem is that it drops the answer in the next available cell which is not always in line with the original row.
Is it possible to drop the answer in the same row please
 
Upvote 0
Try

Code:
Sub Test()
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = 1 To LR
    With Range("B" & i)
        If IsNumeric(.Value) Then .Offset(, 1).Value = .Value
    End With
Next i
End Sub
 
Upvote 0
Vog

This code appears to be not working, I can not see in the code statement were it tells you to drop the information into column C
 
Upvote 0
The .Offset(,1).Value=.Value does that.

Results of a quick test

Excel Workbook
BC
1a
211
322
433
5e
633
744
8r
Sheet1
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,808
Members
452,944
Latest member
2558216095

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