Excel help....fastest finger first....

Log in to stop seeing adverts
This page may contain links to companies such as eBay and Amazon. As an affiliate of these sites I may earn commission if you click the link and make a purchase

Status
Not open for further replies.

Joe_Fox

Well-Known Member
Hello,

I need to add the text "+62" to every cell in a column that has 8 characters.

So if a cell had "45339834" I want to run a macro that changes this to "+62 45339834".

Is this easy peasy? Any pointers would be grand.

Joe
 
Code:
Sub AppendSelection
     dim LoopCell as range
     
     For Each LoopCell in Selection
          if len(LoopCell.Value)=8 then
               LoopCell.Value="+62 " & LoopCell.Value
          end if
     Next
End Sub

works on what cells are selected...
 
you don't need VBA

you could just use formulae

="+62 " & A1

etc
 
Thank you Darth, much obliged.
 
you don't need VBA

you could just use formulae

="+62 " & A1

etc

Yes but that would add it to every cell regardless of whether it had 8 nuimbers in or not, and the implication in the original question was that the +62 needed adding to every cell that has 8 numbers and therefore not if there are not 8 numbers. So the VBA solution would allow for this, whereas your solution doesn't.
 
Yes but that would add it to every cell regardless of whether it had 8 nuimbers in or not, and the implication in the original question was that the +62 needed adding to every cell that has 8 numbers and therefore not if there are not 8 numbers. So the VBA solution would allow for this, whereas your solution doesn't.

pffft

=if(len(a1)=8,"+62 "&a1,a1)
 
Status
Not open for further replies.
Log in to stop seeing adverts

P Pld Pts
1Liverpool2356
2Arsenal2450
3Nottm F2447
4Chelsea2443
5Manchester C  2441
6Newcastle2441
7Bournemouth2440
8Aston Villa2437
9Fulham2436
10Brighton2434
11Brentford2431
12Palace2430
13Manchester U2429
14Tottenham 2427
15West Ham2427
16Everton2326
17Wolves2419
18Leicester2417
19Ipswich2416
20Southampton249
Back
Top