need space between Uppercase

sksanjeev786

Well-known Member
Joined
Aug 5, 2020
Messages
1,004
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
Hi Team,

I need a space between names and want to remove the numbers

Book1
AB
1SanjeevKumar990Sanjeev Kumar
2RajKumar1038Raj Kumar
3VishalKumarSingh221Vishal Kumar Singh
4Anay342Anay
Sheet1


Regards
Sanjeev
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
try this macro:
VBA Code:
Sub test()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 1))
For i = 1 To lastrow
 txt = ""
 For j = 1 To Len(inarr(i, 1))
   tt = Mid(inarr(i, 1), j, 1)
   If Asc(tt) > 64 And Asc(tt) < 91 And j > 1 Then
    txt = txt & " "
   End If
   If Asc(tt) < 58 Then
    Exit For
   End If
   txt = txt & tt
  Next j
  Range(Cells(i, 2), Cells(i, 2)) = txt
 Next i
End Sub
 
Upvote 1
try this macro:
VBA Code:
Sub test()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 1))
For i = 1 To lastrow
 txt = ""
 For j = 1 To Len(inarr(i, 1))
   tt = Mid(inarr(i, 1), j, 1)
   If Asc(tt) > 64 And Asc(tt) < 91 And j > 1 Then
    txt = txt & " "
   End If
   If Asc(tt) < 58 Then
    Exit For
   End If
   txt = txt & tt
  Next j
  Range(Cells(i, 2), Cells(i, 2)) = txt
 Next i
End Sub
Hi,

Thank you so much for your help on this.

This works perfectly...:):)

Just wanted to check can we have these in the Excel formula

i was trying to apply with the below one but not getting the result

=IF(AND(EXACT(PROPER(LEFT(A1,FIND(" ",A1)-1)),LEFT(A1,FIND(" ",A1)-1)),EXACT(PROPER(RIGHT(A1,LEN(A1)-FIND(" ",A1))),RIGHT(A1,LEN(A1)-FIND(" ",A1))))=TRUE,LEFT(A1,FIND(" ",A1)-1)&" "&RIGHT(A1,LEN(A1)-FIND(" ",A1)),A1)

Regards
Sanjeev
 
Upvote 0
Try

Book2
ABC
1SanjeevKumar990Sanjeev Kumar
2RajKumar1038Raj Kumar
3VishalKumarSingh221Vishal Kumar Singh
4Anay342Anay
5
Sheet1
Cell Formulas
RangeFormula
B1:B4B1=IFERROR(REPLACE(IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)),SEARCH(" ",IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)))+2),1),0," "),IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)))
 
Last edited:
Upvote 1
Try

Book2
ABC
1SanjeevKumar990Sanjeev Kumar
2RajKumar1038Raj Kumar
3VishalKumarSingh221Vishal Kumar Singh
4Anay342Anay
5
Sheet1
Cell Formulas
RangeFormula
B1:B4B1=IFERROR(REPLACE(IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)),SEARCH(" ",IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)))+2),1),0," "),IFERROR(REPLACE(LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),AGGREGATE(15,6,FIND(CHAR(ROW($65:$90)),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),2),1),0," "),LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1)))
Wow!!:)

work perfectly :):)

Thank you team for your support on this :)

Regards
Sanjeev
 
Upvote 0
Looking at the two solutions I was interested to note that the vba solution was 294 characters while the formula solution was 1095 characters. I have never manage to write an equation that long!! Probably because I find it easier to write in VBA
 
Upvote 0
Looking at the two solutions I was interested to note that the vba solution was 294 characters while the formula solution was 1095 characters. I have never manage to write an equation that long!! Probably because I find it easier to write in VBA
yes! Thank you so much for your time this.....

Yes formula has multiple conditions due to that it is long
 
Upvote 0
Simpler version of the same formula :

=LET(a,LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),b,CHAR(ROW($65:$90)),c,AGGREGATE(15,6,FIND(b,a,2),1),IFERROR(REPLACE(IFERROR(REPLACE(a,c,0," "),a),AGGREGATE(15,6,FIND(b,IFERROR(REPLACE(a,c,0," "),a),SEARCH(" ",IFERROR(REPLACE(a,c,0," "),a))+2),1),0," "),IFERROR(REPLACE(a,c,0," "),a)))
 
Upvote 1
Simpler version of the same formula :

=LET(a,LEFT(A1,AGGREGATE(15,6,SEARCH({0,1,2,3,4,5,6,7,8,9},A1),1)-1),b,CHAR(ROW($65:$90)),c,AGGREGATE(15,6,FIND(b,a,2),1),IFERROR(REPLACE(IFERROR(REPLACE(a,c,0," "),a),AGGREGATE(15,6,FIND(b,IFERROR(REPLACE(a,c,0," "),a),SEARCH(" ",IFERROR(REPLACE(a,c,0," "),a))+2),1),0," "),IFERROR(REPLACE(a,c,0," "),a)))

Thank you so much sir for providing the help on this :)
 
Upvote 0

Forum statistics

Threads
1,223,937
Messages
6,175,522
Members
452,650
Latest member
Tinfish

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