Macro to find cell, copy and paste the last 4 numerical values into new sheet

dmott92

New Member
Joined
Jun 6, 2018
Messages
1
Hey guys,

I want to create a macro that will find all specific text, copy the last 4 numerical values and paste this into a new sheet.

I get data sets that will contain mutliple cells with the string "Manders' M1 (Above zero intensity of Ch2), X.XXX". I am specifically interested in the numerical value at the end and just want to find all of these and paste them into a new sheet.

I have been playing around trying to get it to work with no luck so far. I imagine that the macro would find and cells with the text "Manders' M1" and copy+paste the right 5 values into a new sheet.

Thanks in advance,
Dan
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Dan,

Welcome to the Board.

You might consider the following...

Code:
Sub AnotherInStringArr()
'1058421
Application.ScreenUpdating = False
Dim ws1 As Worksheet, ws2 As Worksheet
Dim arr As Variant
Dim i As Long, j As Long, k As Long

Set ws1 = ActiveSheet
Set ws2 = Sheets.Add(after:=Sheets(Sheets.Count))
arr = ws1.UsedRange
k = 1

For i = LBound(arr) To UBound(arr)
    For j = 1 To ws1.UsedRange.Columns.Count
        If InStr(arr(i, j), "Manders' M1") > 0 Then
            With ws2.Cells(k, 1)
                .Value = Right(arr(i, j), 5)
                .NumberFormat = "0.000"
            End With
            k = k + 1
        End If
    Next j
Next i
End Sub

Cheers,

tonyyy
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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