Left Trimming VBA

grifdoogindoggy

New Member
Joined
Aug 27, 2019
Messages
21
I'm struggling to find an easy way to simply trim a range of cells in a column (hard coded into VBA) and then left trimming by a number of my choosing (also hardcoded).

I'm looking for something along the lines of this:
Range("A1:A10").FormulaR1C1 = "=LEFT(TRIM(R[]C[],9))"
But it's not working.

Thank you for any help!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Welcome to the Board!

Is that what you are trying to do?
Code:
Sub test()
    Dim cell As Range
    For Each cell In Range("A1:A10")
        cell = Left(Trim(cell), 9)
    Next cell
End Sub
If not, please just explain in plain English exactly what it is you are trying to do.
It might be helpful if you post some data examples, and what you want them to look like after the fact.
 
Last edited:
Upvote 0
Maybe
Code:
Sub grifdoog()
   With Range("A1:A10")
      .Value = Evaluate("if({1},left(trim(" & .Address & "),9))")
   End With
End Sub
 
Upvote 0
Thank you! Do you know a simple way to print each cell on top of another for a specified number of times?

ie for a constant 2:
"A1"
"A1"
"A2"
"A2"
"A3"
"A3"
...

and so on
 
Upvote 0
As this is a totally different question, you will need to start a new thread.
Thanks
 
Upvote 0

Forum statistics

Threads
1,223,099
Messages
6,170,108
Members
452,302
Latest member
TaMere

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