Hi excel users.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
I have a problem where, when I added Application.ScreenUpdating = False to my code it causes all the draw buttons to flicker each time it is run. <o></o>
<o></o>
Without having Application.ScreenUpdating = False in the code, it does not flicker at all. I added it only to speed the code up (which it does), but for some reason it causes all the draw shapes on the worksheet to flicker. This makes no sense to me as it should also stop screen flicker, which was never there to begin with... (using excel 2007)
<o></o>
Anyway code below. Full credit to Ruddles for the code <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" oreferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><vath o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></vath><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape style="WIDTH: 10.8pt; HEIGHT: 10.8pt; VISIBILITY: visible; mso-wrap-style: square" id=Picture_x0020_1 alt="0" type="#_x0000_t75" o:spid="_x0000_i1025"><v:imagedata src="file:///C:\Users\Stephen\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif" o:title="0"></v:imagedata></v:shape><o></o>
Thanks.
<o></o>
I have a problem where, when I added Application.ScreenUpdating = False to my code it causes all the draw buttons to flicker each time it is run. <o></o>
<o></o>
Without having Application.ScreenUpdating = False in the code, it does not flicker at all. I added it only to speed the code up (which it does), but for some reason it causes all the draw shapes on the worksheet to flicker. This makes no sense to me as it should also stop screen flicker, which was never there to begin with... (using excel 2007)
<o></o>
Anyway code below. Full credit to Ruddles for the code <?xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" /><v:shapetype id=_x0000_t75 stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" oreferrelative="t" o:spt="75" coordsize="21600,21600"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><vath o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"></vath><o:lock aspectratio="t" v:ext="edit"></o:lock></v:shapetype><v:shape style="WIDTH: 10.8pt; HEIGHT: 10.8pt; VISIBILITY: visible; mso-wrap-style: square" id=Picture_x0020_1 alt="0" type="#_x0000_t75" o:spid="_x0000_i1025"><v:imagedata src="file:///C:\Users\Stephen\AppData\Local\Temp\msohtmlclip1\01\clip_image001.gif" o:title="0"></v:imagedata></v:shape><o></o>
Code:
Public Sub ExtractRandomWord()
Dim iLastRow As Long
Dim iLastNew As Long
Dim iPointer As Long
Dim iInd As Long
Dim iSwap As String
Dim ws As Worksheet
Set ws = Worksheets("data")
Application.ScreenUpdating = False
iLastRow = ws.Cells(Rows.Count, 1).End(xlUp).Row
iLastNew = ws.Cells(Rows.Count, 3).End(xlUp).Row
If iLastRow > 1 Then
iPointer = WorksheetFunction.RandBetween(2, iLastRow)
iLastNew = iLastNew + 1
ws.Cells(iLastNew, 3) = ws.Cells(iPointer, 1)
ActiveSheet.Shapes("TextBox 1").TextFrame.Characters.Text = ws.Cells(iPointer, 1)
For iInd = iPointer To iLastRow + 1
ws.Cells(iInd, 1) = ws.Cells(iInd + 1, 1)
Next iInd
iLastRow = iLastRow - 1
If iLastRow = 1 Then ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Reset List"
Else
ActiveSheet.Shapes("TextBox 1").TextFrame.Characters.Text = ""
For iPointer = 2 To iLastNew
For iInd = iPointer + 1 To iLastNew
If ws.Cells(iPointer, 3) > ws.Cells(iInd, 3) Then
iSwap = ws.Cells(iPointer, 3)
ws.Cells(iPointer, 3) = ws.Cells(iInd, 3)
ws.Cells(iInd, 3) = iSwap
End If
Next iInd
ws.Cells(iPointer, 1) = ws.Cells(iPointer, 3)
ws.Cells(iPointer, 3).ClearContents
Next iPointer
ActiveSheet.Shapes("Button 1").TextFrame.Characters.Text = "Next Word"
End If
Application.ScreenUpdating = True
End Sub
Thanks.