texto to column by formula

doriannjeshi

Active Member
Joined
Apr 5, 2015
Messages
337
Office Version
  1. 365
Platform
  1. Windows
Hi,

trying to trim this to the second delimiter by using a formula

111-11-1
result
111-11

exp2
ddd-dd-1
result
ddd-dd
 
Maybe this:

Code:
Sub text2colls()
With Range(Cells(2, ActiveCell.Column), Cells(Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp).Row, ActiveCell.Column))
.Value = ("=IFERROR(LEFT(RC[-1],SEARCH(""|"",SUBSTITUTE(RC[-1],""-"",""|"",2))-1),RC[-1])")
.Value = .Value
End With
End Sub

Unfortunately is deleteing the leading zeroes when I set it to the first delimiter

second delimiter the way you ve set it is fine
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Try:

With Range(Cells(2, ActiveCell.Column), Cells(Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp).Row, ActiveCell.Column))
.Value = ( "=IFERROR(LEFT(RC[-1],FIND(""-"",RC[-1],FIND(""-"",RC[-1])+1)-1),"""")"
.Value = .Value
End With
End Sub

(reply to Post #30)
 
Last edited:
Upvote 0
This work?

Code:
Sub text2colls()
Dim c As Range
For Each c In Range(Cells(2, ActiveCell.Column), Cells(Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp).Row, ActiveCell.Column))
c.Value = ("=IFERROR(LEFT(RC[-1],SEARCH(""|"",SUBSTITUTE(RC[-1],""-"",""|"",2))-1),RC[-1])")
c.Value = "'" & c.Value
Next
End Sub
 
Upvote 0
This work?
Code:
 Sub text2colls() Dim c As Range For Each c In Range(Cells(2, ActiveCell.Column), Cells(Cells(Rows.Count, ActiveCell.Column - 1).End(xlUp).Row, ActiveCell.Column)) c.Value = ("=IFERROR(LEFT(RC[-1],SEARCH(""|"",SUBSTITUTE(RC[-1],""-"",""|"",2))-1),RC[-1])") c.Value = "'" & c.Value Next End Sub
I want to use this formula in the above macro ActiveCell.FormulaR1C1 = "=SUMIF(C[-5],RC[-3],C[-6])" Range("G2").Select How can i do it, the macro it's supposed to execute the sumif formula and copy it down until there is data in the adjacent column and then copy and paste the entire column so the formula goes away.. thanks in advance
 
Upvote 0
Something like this?


Excel 2010
ABCDE
1NameNumber
2Q94Q
3W3W
4E39E
5R19R
6T56T
7Y8Y
8U31U
9U58I
10I20O
11O19P
12P63A
13A12S
14S88D
15D75
16Q43
17W63
18E60
19R26
20Q68
21W100
22Q84
23Q26
24Q41
25U63
26U32
27Y33
28Y93
29Y62
30A34
31A89
32A74
33Q66
Sheet1


Code:
Sub countifspaste()
Dim lra%, lre%
lra = Cells(Rows.Count, 1).End(xlUp).Row
lre = Cells(Rows.Count, 5).End(xlUp).Row
Range("F2:F" & lre).FormulaR1C1 = "=sumif(R2C1:R" & lra & "C1,RC[-1],R2C2:R" & lra & "C2)"
End Sub


Excel 2010
ABCDEF
1NameNumber
2Q94Q422
3W3W166
4E39E99
5R19R45
6T56T56
7Y8Y196
8U31U184
9U58I20
10I20O19
11O19P63
12P63A209
13A12S88
14S88D75
15D75
16Q43
17W63
18E60
19R26
20Q68
21W100
22Q84
23Q26
24Q41
25U63
26U32
27Y33
28Y93
29Y62
30A34
31A89
32A74
33Q66
Sheet1
Cell Formulas
RangeFormula
F2=SUMIF($A$2:$A$33,E2,$B$2:$B$33)
 
Upvote 0
Change # to whatever in case "#" occurs in your original string
=LEFT(B21,FIND("#",SUBSTITUTE(B21,"-","#",2))-1)
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,390
Members
452,909
Latest member
VickiS

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