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

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
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,223,904
Messages
6,175,295
Members
452,631
Latest member
a_potato

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