Use Array to only copy number in cell and not text

Charlreena

New Member
Joined
Jul 17, 2018
Messages
2
I have a basic array function that copies various cells and pastes them into a database in the correct order. I'm adding in some additional columns & some of the cells I need the array to copy are made up of numbers & text. I only need the array to copy and paste the number and not the text. Is there a way to do this? I understand the easiest way would be to split out the text and numbers originally, but it's a document that's converted into excel & that's how it converts unfortunately.

This is my code.

Code:
 Dim lr As Long, i As Long, cls

cls = Array("A2", "F3", "F4", "F5", "C2", "G2", "L2", "U2", "U3", "W2", "W3", "O2", "O3", "S2", "S3")
With Sheets("example")
    lr = WorksheetFunction.Max(3, .Range("C" & Rows.Count).End(xlUp).Row + 1)
    For i = LBound(cls) To UBound(cls)
        .Cells(lr, i + 3).Value = Sheets("example").Range(cls(i)).Value
        If .Cells(lr, i + 3) < 0 Then .Cells(lr, i + 3) = .Cells(lr, i + 3) * -1
        If .Cells(lr, i + 3) = "" Then .Cells(lr, i + 3) = 0
    Next i
End With

Thanks
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Watch MrExcel Video

Forum statistics

Threads
1,129,695
Messages
5,637,853
Members
416,986
Latest member
zmartee

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
Top