Apr 8, 2009 #1 Groves22 Technical User Joined Jan 29, 2009 Messages 102 Location US Is there a way I can add to each unique number in a cell. For example: I have 00378 in a cell. Is there something I can do to add 5 to each number in that cell? The end result would be 55823. It's in a mod 10 format when adding. Thanks
Is there a way I can add to each unique number in a cell. For example: I have 00378 in a cell. Is there something I can do to add 5 to each number in that cell? The end result would be 55823. It's in a mod 10 format when adding. Thanks
Apr 8, 2009 #2 AnotherHiggins Technical User Joined Nov 25, 2003 Messages 6,259 Location US FYI: This should be possible without VBA by using an array formula But since we're talking about VBA, this should get you started: Code: For i = 1 To Len(Range("A1")) foo = foo & (Mid(Range("A1"), i, 1) + 5) Mod 10 Next i Range("A2") = foo [tt][blue]-John[/blue][/tt] [tab][red]The plural of anecdote is not data[/red] Help us help you. Please read FAQ 181-2886 before posting. Upvote 0 Downvote
FYI: This should be possible without VBA by using an array formula But since we're talking about VBA, this should get you started: Code: For i = 1 To Len(Range("A1")) foo = foo & (Mid(Range("A1"), i, 1) + 5) Mod 10 Next i Range("A2") = foo [tt][blue]-John[/blue][/tt] [tab][red]The plural of anecdote is not data[/red] Help us help you. Please read FAQ 181-2886 before posting.
Apr 8, 2009 Thread starter #3 Groves22 Technical User Joined Jan 29, 2009 Messages 102 Location US Hey John... Thanks for the tip. I wasn't quite sure what the "foo" was so I found another way using your VBA. Code: For j = 2 To 4005 k = 0 For i = 1 To Len(Cells(j, 2)) Cells(j, 3 + k) = (Mid(Cells(j, 2), i, 1) + 5) Mod 10 k = k + 1 Next i Next j Not the cleanest but it got the job done! Thanks Upvote 0 Downvote
Hey John... Thanks for the tip. I wasn't quite sure what the "foo" was so I found another way using your VBA. Code: For j = 2 To 4005 k = 0 For i = 1 To Len(Cells(j, 2)) Cells(j, 3 + k) = (Mid(Cells(j, 2), i, 1) + 5) Mod 10 k = k + 1 Next i Next j Not the cleanest but it got the job done! Thanks
Apr 8, 2009 #4 S SkipVought Programmer Joined Dec 4, 2001 Messages 47,492 Location US foo is chaw. Chaw is man chew. Therefore, foo::man chew is TRUE Skip, Don't let the Diatribe... talk you to death! Just traded in my old subtlety... for a NUANCE! Upvote 0 Downvote
foo is chaw. Chaw is man chew. Therefore, foo::man chew is TRUE Skip, Don't let the Diatribe... talk you to death! Just traded in my old subtlety... for a NUANCE!