Application.left VBA

J

Jeff

Can somenone help fixing the VBA macro?
Sub trimit()
Dim rng As Range
Set target = Range("A2:H" & Range("A2").End(xlDown).Row)
Set rng1 = Range("F2:H" & Range("F2").End(xlDown).Row)
For Each cell In target
cell.Value = Trim(Application.Left(Range("target")), 10, 0
Range("rng1") = cell.Value
Next
End Sub
 
D

Don Guillett

maybe to get the left 10 characters in cell F.

Sub trimit()
for each c in Range("A2:H" & Range("A2").End(xlDown).Row)
c.Value = left(c.offset(,5),10)
'or to trim the cell first and then get the left 10
'c.Value = left(application.trim(c.offset(,5)),10)

Next c
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top