Code Continually runs

andrewb90

Well-known Member
Joined
Dec 16, 2009
Messages
1,077
Hello all,


I have a macro that does what needs to be done, then while it appears to not be doing anything in excel, VBA shows it continually running, and I'm not sure what I've done to cause that. Any help would be greatly appreciated.

Code:
Sub mchoice2()On Error Resume Next
Dim R As Long, C As Long, VR As Range, Cell As Range
Set VR = ActiveWindow.VisibleRange
sStartSheet = ActiveSheet.Name
    Sheets("logos").Select
    ActiveSheet.Shapes.Range(Array("lologo1")).Select
    Selection.copy
    Worksheets(sStartSheet).Select
    rep_count = 0
    Do
    DoEvents
    'MsgBox "HI"
        Do
            R = Application.RandBetween(1, VR.Rows.Count - 1)
            C = Application.RandBetween(1, VR.Columns.Count - 1)
            Set Cell = VR.Cells(R, C)
        Loop Until Cell.EntireColumn.Hidden = False And Cell.EntireRow.Hidden = False
        Cell.Select
        
        ActiveSheet.Paste
        rep_count = rep_count + 1
        timeoutq (0.2)
Loop Until rep_count = 6
MsgBox "start"
timeoutq (2.01)
MsgBox "end"
'comment out below


Do While ActiveSheet.Shapes("lologo1").Visible = True
'this is doing everything right except for the error at the end
    With ActiveSheet.Shapes("lologo1")
        rep_countB = 0
        Do
        DoEvents
        ActiveSheet.Shapes.Range(Array("lologo1")).Select
        Selection.ShapeRange.SoftEdge.Radius = Selection.ShapeRange.SoftEdge.Radius + 3
            rep_countB = rep_countB + 1
            timeoutq (0.01)
    Loop Until rep_countB = 6
        ActiveSheet.Shapes.Range(Array("lologo1")).Delete
    
    End With


Loop






End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,215,444
Messages
6,124,891
Members
449,194
Latest member
JayEggleton

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