Take value after comma, cut and paste in another column

cgmojoco

Well-known Member
Joined
Jan 15, 2005
Messages
699
Hi there-

Need a macro that will search each cell in column J
Find value after the ","
Place the value in cell column H on the same line


Example of cell in column J
HENDERN, 12

I need to extract the 12 and put it in the H column on the same row

Also need a check run to make sure each value in column J has a comma in it, if not, error.
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi
Code:
Sub test()
Dim r As Range, x, ff As String
With ActiveSheet
    Set r = .Columns("j").Find(",", , , xlPart)
    If Not r Is Nothing Then
        ff = r.Address
        Do
            x = Trim(Mid(r, InStr(r, ",") + 1))
            If IsNumeric(x) Then x = CDbl(x)
            r.Offset(, 1) = x
            Set r = .Columns("j").FindNext(r)
        Loop Until r.Address = ff
    End If
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,395
Messages
6,119,265
Members
448,881
Latest member
Faxgirl

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