Add 1 to every number in list of numbers in a cell

Usercode

Board Regular
Joined
Aug 18, 2017
Messages
107
Office Version
  1. 2016
Platform
  1. Windows
I have a list of numbers in a cell and I'd like to add +1 to each of values separated by comma in the cell.

For example;
if A1 is : 1,5,10 ; then B1: 2,6,11

if A2 is : 5,11,20,23 ; then B2: 6,12,21,24

if A3 is: 7,10 ; then B3: 8,11.

I have only one digit and double digit numbers.

How can I do this calculation without splitting the values into different columns? please.

I can use both formula or vba solution. Thanks.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
How about
VBA Code:
Function Usercode(Txt As String) As String
   Dim Sp As Variant
   Dim i As Long
   
   Sp = Split(Txt, ",")
   For i = 0 To UBound(Sp)
      Sp(i) = Sp(i) + 1
   Next i
   Usercode = Join(Sp, ",")
End Function
used like
+Fluff v2.xlsm
AB
1
21,5,102,6,11
35,11,20,236,12,21,24
47,10,998,11,100
5
Main
Cell Formulas
RangeFormula
B2:B4B2=Usercode(A2)
 
Upvote 0
Solution
We can make Fluff's function a little bit more compact...
VBA Code:
Function Usercode(Txt As String) As String
   Dim V As Variant
   For Each V In Split(Txt, ",")
     Usercode = Replace(Trim(Usercode & " " & V + 1), " ", ",")
   Next
End Function
 
Upvote 0

Forum statistics

Threads
1,215,036
Messages
6,122,794
Members
449,095
Latest member
m_smith_solihull

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