Advertisement
Guest User

Untitled

a guest
Jun 30th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Sub Loop_Exampl()
  2. Dim Firstrow As Long
  3. Dim Lastrow As Long
  4. Dim Lrow As Long
  5. Dim CalcMode As Long
  6. Dim ViewMode As Long
  7.  
  8. With Application
  9. CalcMode = .Calculation
  10. .Calculation = xlCalculationManual
  11. .ScreenUpdating = False
  12. End With
  13.  
  14. 'We use the ActiveSheet but you can replace this with
  15. 'Sheets("MySheet")if you want
  16. With ActiveSheet
  17.  
  18. 'We select the sheet so we can change the window view
  19. .Select
  20.  
  21. 'If you are in Page Break Preview Or Page Layout view go
  22. 'back to normal view, we do this for speed
  23. ViewMode = ActiveWindow.View
  24. ActiveWindow.View = xlNormalView
  25.  
  26. 'Turn off Page Breaks, we do this for speed
  27. .DisplayPageBreaks = False
  28.  
  29. 'Set the first and last row to loop through
  30. Firstrow = .UsedRange.Cells(1).Row
  31. Lastrow = .UsedRange.Rows(.UsedRange.Rows.Count).Row
  32.  
  33. 'We loop from Lastrow to Firstrow (bottom to top)
  34. For Lrow = Lastrow To Firstrow Step -1
  35.  
  36. 'We check the values in the A column in this example
  37. With .Cells(Lrow, "B")
  38.  
  39. With ActiveCell.Characters(Start:=2, Length:=1).Font
  40. .Superscript = False
  41. .Subscript = True
  42.  
  43. End With
  44.  
  45. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement