Advertisement
Guest User

Untitled

a guest
May 16th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub LoopThroughString()
  2.  
  3. Dim cellWithinRange As Object
  4. Dim selectedRange As Range
  5. Dim newText As String
  6. Dim LookInHere As String
  7. Dim Counter As Integer
  8.  
  9. For Each cell In Selection
  10.  
  11.  
  12. 'Use your own text here
  13. LookInHere = cell.Value
  14.  
  15.  
  16.     For Counter = 1 To Len(LookInHere)
  17.         If (Mid(LookInHere, Counter, 1)) = "0" Then
  18.             newText = newText
  19.         ElseIf (Mid(LookInHere, Counter, 1)) <> "0" Then
  20.             newText = newText & (Mid(LookInHere, Counter, 100))
  21.             Exit For
  22.            
  23.            
  24.         End If
  25.     Next
  26.    
  27. cell.Value = newText
  28. newText = ""
  29. Next cell
  30.  
  31.  
  32.  
  33.  
  34. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement