Loop Error in VBA

sasha1

New Member
Joined
Mar 11, 2009
Messages
1
I am a pretty inexperienced user of VBA but hoping someone can help... Why would I bet getting a "Loop without Do" error on the following code?

*********************
Sub OverUnder()

Sheets("Weekly Input Sheet").Range("B4").Select
CurrWkNum = ActiveCell.Value
Sheets("Sample File").Select

Do While Error = False
ActiveSheet.Next.Select
CurrSheetName = ActiveSheet.Name
Columns("E:E").Select
Selection.Find(What:=CurrWkNum, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 5).Select
If ActiveCell.Value > 0 Then
Range(Selection, ActiveCell.Offset(0, 3)).Select
Selection.Copy
Sheets("Profitability Dashboard").Select
Cells.Select
Selection.Find(What:="Which are over and by what %", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets(CurrSheetName).Select
Range("A5").Select
Range(Selection, ActiveCell.Offset(0, 3)).Select
Selection.Copy
Sheets("Profitability Dashboard").Select
Cells.Select
Selection.Find(What:="Which are over and by what %", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(xlDown).Select
ActiveCell.Offset(0, -2).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets(CurrSheetName).Select
Else
Loop

End Sub
****************

thanks in advance for the help!!!
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Because you don't have End If anywhere?

Try replacing Else with End If.:)
 
Upvote 0
Weclome to the board!

At a quick glance, and without copying and testing your code I would say your error is in the do line, should be Do, not Do While, or alternatively you could keep Do While and delete Else and Loop from the end.

Hope this helps

Someone please correct me if I'm wrong there, I don't use Do - Loop as a rule so not 100% certain on this.
 
Upvote 0

Forum statistics

Threads
1,222,173
Messages
6,164,388
Members
451,888
Latest member
OhSheet

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