Hello all, I had been looking online to find a solution to my problem and was lucky enough to stumble on this board. I had 2 questions someone on here can hopefully solve.
When working with a group of cells (say 10x10) with a number in each cell, what is the easiest way to count the number of 3’s for each cell (ex: 23253.213 would be 3)?
Secondly, how do I change each 3 to an 8 one at a time for a cell, like change3once = 28253.213, change3twice = 28258.213, etc?
Thank you in advance
Your first question can be solved with
=LEN(A1)-LEN(SUBSTITUTE(A1,3,))
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
BUMB: Still unable to figure this out
Secondly, how do I change each 3 to an 8 one at a time for a cell, like change3once = 28253.213, change3twice = 28258.213, etc?
Please use code tags when editing VBA Thx
Quoting entire posts clutters the forum and makes threads hard to read !
If you are pleased with a member's answer then use the Star icon to rate it
Click here to see forum rules
Try
Sub Test() X = 23253.213 Y = ChangeSpecial(X, 3, 8, 2) End Sub Function ChangeSpecial(ByVal MyNumber As Double, NumberToReplace As Integer, NumberToReplaceWith As Integer, Count As Long) As Double Dim N As Integer, M As Integer For N = 1 To Len(MyNumber) If Mid(MyNumber, N, 1) = NumberToReplace Then M = M + 1 If M <= Count Then MyNumber = Left(MyNumber, N - 1) & NumberToReplaceWith & Right(MyNumber, Len(MyNumber) - N + 1) End If End If Next N ChangeSpecial = Val(MyNumber) End Function
Martin
Eighty Twenty Spreadsheet Automation http://homepage.ntlworld.com/martin.rice1/ for all your Excel customisation and consulting needs.
If my solution has saved you time and/or money, please consider donating to Cancer Research UK.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks