How to add a trim formula using VBA code

Kenor

Board Regular
Joined
Dec 8, 2020
Messages
116
Office Version
  1. 2016
Platform
  1. Windows
Hi Everyone..

I have used the VBA code below to transfer data from another sheet to another sheet before.
___________________________________________________________

Sub RoundedRectangle6_Click()

Dim wsIN As Worksheet
Dim wsRegister_IN As Worksheet
Dim CopyLastRow As Long
Dim DestLastRow As Long

Set wsIN = Worksheets("IN")
Set wsRegister_IN = Worksheets("Register IN")

CopyLastRow = wsIN.Range("A" & wsIN.Rows.Count).End(xlUp).Row + 1
DestLastRow = wsRegister_IN.Range("A" & wsRegister_IN.Rows.Count).End(xlUp).Row + 1

wsIN.Range("A3", "J" & CopyLastRow).Copy Destination:=wsRegister_IN.Range("A" & DestLastRow)
wsIN.Range("A3", "A" & CopyLastRow).EntireRow.Delete

End Sub

______________________________________________________________

But I have one problem that all the data in the D & E column has extra space from the text.

I need to remove all the extra space to make sure the formulas in the other sheets can track all the available data.

This is how data with extra space from text >>
1631454052838.png



So I want to add a trim formula in the VBA code above.

Or is there another solution ?

Anyone can help me..


Thanks
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,223,909
Messages
6,175,313
Members
452,634
Latest member
cpostell

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