Need to delete characters in a column

KAZSTREBOR

New Member
Joined
Feb 18, 2021
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hi there!

I need to delete characters generated from a report that come after the space. (eg. 1234 cds), the characters vary so I can't target specific ones.
I'm currently trying to use this code in VBA that I modified from this thread but I can't figure out why it is also deleting the first character in the cell. I'm pretty new to this so any
help is much appreciated. Thanks!

VBA Code:
Sub Test()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    On Error Resume Next
    For Each rng In Range("B1:B" & LastRow)
        rng = Left(Mid(rng, 2, 9999), WorksheetFunction.Find(" ", rng) - 2)
    Next rng
    Application.ScreenUpdating = True
End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi & welcome to MrExcel.
How about
VBA Code:
Sub Kazstrebor()
   With Range("B1", Range("B" & Rows.Count).End(xlUp))
      .Value = Evaluate(Replace("left(@,find("" "",@&"" ""))", "@", .Address))
   End With
End Sub
 
Upvote 0
Perhaps TextToColumns.
VBA Code:
With Range("B:B")
    Range(.Cells(1, 1), .Cells(Rows.Count).End(xlUp)).TextToColumns Destination:=.Cells(1,1), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=True, Tab:=False, Semicolon:=False, Comma:=False, _
        Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 9), Array(3, 9), Array(4, 9), Array(5, 9), Array(10, 9)), TrailingMinusNumbers:=True
End With
 
Upvote 0
Solution

Forum statistics

Threads
1,214,972
Messages
6,122,530
Members
449,088
Latest member
RandomExceller01

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