How to erase spaces from C behind the text?

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
380
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

In the below table I have 6 spaces behind the "location" text in column C. Is there a way to delete all off them in an instance. This sheet is a part of 2000 lines, so that's why I ask.

Thank you for your time.

Text 1Location3Text 45Itemcode6Text 7Query line
update voorrd set maglok = 'P02B ' where artcode ='100000' and magcode ='1'update voorrd set maglok = 'P02B ' where artcode ='100000' and magcode ='1'
update voorrd set maglok = 'P04B ' where artcode ='100001' and magcode ='1'update voorrd set maglok = 'P04B ' where artcode ='100001' and magcode ='1'
update voorrd set maglok = 'P02B ' where artcode ='100002' and magcode ='1'update voorrd set maglok = 'P02B ' where artcode ='100002' and magcode ='1'
update voorrd set maglok = 'P04B ' where artcode ='100003' and magcode ='1'update voorrd set maglok = 'P04B ' where artcode ='100003' and magcode ='1'
update voorrd set maglok = 'P02B ' where artcode ='100004' and magcode ='1'update voorrd set maglok = 'P02B ' where artcode ='100004' and magcode ='1'
update voorrd set maglok = 'P01B ' where artcode ='100006' and magcode ='1'update voorrd set maglok = 'P01B ' where artcode ='100006' and magcode ='1'
update voorrd set maglok = 'P03B ' where artcode ='100007' and magcode ='1'update voorrd set maglok = 'P03B ' where artcode ='100007' and magcode ='1'
update voorrd set maglok = 'Q07A ' where artcode ='100008' and magcode ='1'update voorrd set maglok = 'Q07A ' where artcode ='100008' and magcode ='1'
update voorrd set maglok = 'Q07A ' where artcode ='100009' and magcode ='1'update voorrd set maglok = 'Q07A ' where artcode ='100009' and magcode ='1'
update voorrd set maglok = 'Q08B ' where artcode ='100010' and magcode ='1'update voorrd set maglok = 'Q08B ' where artcode ='100010' and magcode ='1'
update voorrd set maglok = 'Q07A ' where artcode ='100011' and magcode ='1'update voorrd set maglok = 'Q07A ' where artcode ='100011' and magcode ='1'
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
How about
VBA Code:
Sub Romano()
   With Range("C2", Range("C" & Rows.Count).End(xlUp))
      .Value = Evaluate("trim(" & .Address & ")")
   End With
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub Romano()
   With Range("C2", Range("C" & Rows.Count).End(xlUp))
      .Value = Evaluate("trim(" & .Address & ")")
   End With
End Sub
This definitely did the trick. Thank you and have a great day.
 
Upvote 0
Since it appears there are no spaces in the Location codes, what about just Find/Replace, either with the code below or manually?

VBA Code:
Sub Romano_v2()
   Columns("C").Replace " ", "", xlPart
End Sub

BTW, with XL2BB I would recommend using Mini Sheet over Table Only since that more clearly shows what columns/rows are involved.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,907
Messages
6,175,301
Members
452,633
Latest member
DougMo

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