![]() |
Please explain code
Could someone please explain to me what the code below is doing. It is part
of a macro to insert rows, but each time I run the macro its going to Endsub. On Error GoTo EndSub Application.EnableCancelKey = xlDisabled ActiveSheet.Select Let Back = activecell.Column * (-1) + 3 Selection.Offset(0, Back).Range("A1").Select Let test = activecell If test = 1 Then GoTo Continue If test = 0 Then GoTo EndSub GoTo EndSub |
Please explain code
Karen,
Comment out the 'OnError..." statement so you can see which line is causing the error. NickHK "Karen McKenzie" wrote in message ... Could someone please explain to me what the code below is doing. It is part of a macro to insert rows, but each time I run the macro its going to Endsub. On Error GoTo EndSub Application.EnableCancelKey = xlDisabled ActiveSheet.Select Let Back = activecell.Column * (-1) + 3 Selection.Offset(0, Back).Range("A1").Select Let test = activecell If test = 1 Then GoTo Continue If test = 0 Then GoTo EndSub GoTo EndSub |
Please explain code
Weird code. I steped through the code without any errors. Had to add labels
to get it to compile. Have you steped through the code. Highlight the row that starts with Application and press F9. the line should go yellow. Then Press F8 to step through the code. The code is really doing nothing except changing the selected cell. Sub weird() On Error GoTo endsub Application.EnableCancelKey = xlDisabled ActiveSheet.Select 'take active cell column multiply by -1 and adds 3 Let Back = ActiveCell.Column * (-1) + 3 'changes the column of the selected cell 'this is weird! 'Not sure if it is refereing cell A1 or the selected cell Selection.Offset(0, Back).Range("A1").Select 'Tests the value of the active cell Let test = ActiveCell If test = 1 Then GoTo continue If test = 0 Then GoTo endsub GoTo endsub continue: endsub: End Sub "Karen McKenzie" wrote: Could someone please explain to me what the code below is doing. It is part of a macro to insert rows, but each time I run the macro its going to Endsub. On Error GoTo EndSub Application.EnableCancelKey = xlDisabled ActiveSheet.Select Let Back = activecell.Column * (-1) + 3 Selection.Offset(0, Back).Range("A1").Select Let test = activecell If test = 1 Then GoTo Continue If test = 0 Then GoTo EndSub GoTo EndSub |
Please explain code
The code always takes the active cell back to column C. There are two
conditions that takes the code to EndSub. One is when there's an error and the other is when the variable "test" (which is column C in the current row) is blank or equal to 0. "Karen McKenzie" wrote: Could someone please explain to me what the code below is doing. It is part of a macro to insert rows, but each time I run the macro its going to Endsub. On Error GoTo EndSub Application.EnableCancelKey = xlDisabled ActiveSheet.Select Let Back = activecell.Column * (-1) + 3 Selection.Offset(0, Back).Range("A1").Select Let test = activecell If test = 1 Then GoTo Continue If test = 0 Then GoTo EndSub GoTo EndSub |
All times are GMT +1. The time now is 05:49 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com