cycle macro

overbet

Board Regular
Joined
Jul 9, 2010
Messages
63
Office Version
  1. 2010
Is it possible in vba to have a macro button that cycles through preset data? Example would be in cell A1 the data contains the text "A". When pressing the button once the data changes from "A" to "B" when pressed again the text changes from "B" to "C" when pressed again the text changes "C" to "D" and when pressed again the data changes from "D" to "A" starting the cycle over again. I have searched to the best of my ability, but I am unable to see if this is even possible. Thanks for your comments.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
What are the preset values?
Will they really be A,B,C,D?
 
Upvote 0
Ok, how about
VBA Code:
Sub overbet()
   With Range("a1")
      .Value = IIf(Asc(.Value) = 68, "A", Chr(Asc(.Value) + 1))
   End With
End Sub
 
Upvote 0
Cool beans. I didnt even think it was possible. Thank you much sir/maam.
 
Upvote 0
Ok, how about
VBA Code:
Sub overbet()
   With Range("a1")
      .Value = IIf(Asc(.Value) = 68, "A", Chr(Asc(.Value) + 1))
   End With
End Sub
Doh can i trouble you once more? Is there anyway to make it on the selection of rows in column A rather than just cell A1. Im sorry I should have posted that in my original question, but I didnt consider it. The data is always in column A but over different rows sometimes.
 
Upvote 0
Do you mean a single selected cell or multiple cells?
 
Upvote 0
Do you mean a single selected cell or multiple cells?
Multiple rows and they are different on different days. Sometimes its a half dozen sometimes more or less and in different row numbers.
 
Upvote 0
Ok, how about
VBA Code:
Sub overbet()
   Dim Cl As Range
   For Each Cl In Intersect(Selection, Range("A:A"))
      Cl.Value = IIf(Asc(Cl.Value) = 68, "A", Chr(Asc(Cl.Value) + 1))
   Next Cl
End Sub
 
Upvote 0
Solution
That cycles but it goes through the entire alphabet then gets into symbols. Is there anyway to make it stop cycling at D value and start over at A value?
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,901
Members
449,097
Latest member
dbomb1414

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