VBA Code to extract number and paste

Wafee

Board Regular
Joined
May 27, 2020
Messages
104
Office Version
  1. 2013
Platform
  1. Windows
Hi,
I am trying to paste data from A,B columns from sheet1 to Aand B sheet2. For the A column , while pasting data I want to paste only numbers from each cells of sheet1. And for B column while pasting i want to remove first 10 letters from left and the paste it. Can someone help me with a code which works faster and dynamic as I am dealing with large amounts of data. Thanks in advance.
 
Ok, but I still need a sample of your actual data.

Hi Fulff,
Attached image is what I can provide due to confidentiality of the data. But I assure that the "A" column data is same as the original data. I basically want to have the level in numerics and Range as per the level. Thanks in advance.
 

Attachments

  • Webp.net-compress-image (1).jpg
    Webp.net-compress-image (1).jpg
    211.8 KB · Views: 7
Upvote 0

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Try
VBA Code:
Sub Wafee()
   Dim Ary As Variant
   Dim i As Long
   With Sheets("Sheet1")
      Ary = Range("A1:B" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For i = 1 To UBound(Ary)
      Ary(i, 1) = val(Ary(i, 1))
      Ary(i, 2) = Mid(Ary(i, 2), 11)
   Next i
   Sheets("Sheet2").Range("A1").Resize(UBound(Ary), 2).Value = Ary
End Sub
If this does not work then you will need to supply some sample data. I cannot do anything with an image, especially when it does not show what is in column B.
To get help, there are times you need to help us.
 
Upvote 0
Try
VBA Code:
Sub Wafee()
   Dim Ary As Variant
   Dim i As Long
   With Sheets("Sheet1")
      Ary = Range("A1:B" & .Range("A" & Rows.Count).End(xlUp).Row).Value2
   End With
   For i = 1 To UBound(Ary)
      Ary(i, 1) = val(Ary(i, 1))
      Ary(i, 2) = Mid(Ary(i, 2), 11)
   Next i
   Sheets("Sheet2").Range("A1").Resize(UBound(Ary), 2).Value = Ary
End Sub
If this does not work then you will need to supply some sample data. I cannot do anything with an image, especially when it does not show what is in column B.
To get help, there are times you need to help us.
That worked perfectly. Thank you mate??
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,865
Messages
6,133,132
Members
449,781
Latest member
lightbucket

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