Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Would someone explain what this code does? | Excel Programming | |||
VBA code not working- repost to further explain problem | Excel Programming | |||
Please Explain Two Lines of Code | Excel Programming | |||
Can someone explain this code to me | Excel Programming | |||
Please explain why following code doesn't work.... | Excel Programming |