Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Would someone explain what this code does? John Smith Excel Programming 0 December 6th 06 01:02 AM
VBA code not working- repost to further explain problem [email protected] Excel Programming 8 August 29th 06 09:15 PM
Please Explain Two Lines of Code ca1358 Excel Programming 1 January 18th 06 04:47 PM
Can someone explain this code to me dht[_2_] Excel Programming 1 September 13th 04 12:03 PM
Please explain why following code doesn't work.... FMNT80 Excel Programming 2 July 23rd 03 06:07 PM


All times are GMT +1. The time now is 11:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"