Deleting Data after Extracting

madhuchelliah

Board Regular
Joined
Nov 22, 2017
Messages
226
Office Version
  1. 2019
Platform
  1. Windows
Hello all, i have created a macro to extract the data from A column except 1st word. But i could not find a way to delete those extracted data from A column. Please guide me to acheive that. Thank you.

My macro example.

VBA Code:
Sub DeLeft()
Dim i As Long, d As Long
Dim Cel As Range
Dim Rng As Range
Set Rng = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
For Each Cel In Rng
i = Len(Cel)
d = InStr(i, Cel, " ")
If Not d = 0 Then Cel.Offset(, 1).Value = Right(Cel, l - d)
Next Cel
End Sub
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
How about
VBA Code:
Sub DeLeft()
Dim i As Long, d As Long
Dim Cel As Range
Dim Rng As Range
Set Rng = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
For Each Cel In Rng
   d = InStr(1, Cel, " ")
   Cel.Resize(, 1 - (d > 0)).Value = Split(Cel, " ", 2)
Next Cel
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub DeLeft()
Dim i As Long, d As Long
Dim Cel As Range
Dim Rng As Range
Set Rng = Range("A2:A" & Range("A" & Rows.Count).End(xlUp).Row)
For Each Cel In Rng
   d = InStr(1, Cel, " ")
   Cel.Resize(, 1 - (d > 0)).Value = Split(Cel, " ", 2)
Next Cel
End Sub
It is working as expected. Thanks for your time.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,738
Messages
6,180,673
Members
452,993
Latest member
FDARYABEE

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