ScoobyNet.com - Subaru Enthusiast Forum

ScoobyNet.com - Subaru Enthusiast Forum (https://www.scoobynet.com/)
-   Computer & Technology Related (https://www.scoobynet.com/computer-and-technology-related-34/)
-   -   VB for excel - easy one (https://www.scoobynet.com/computer-and-technology-related-34/208523-vb-for-excel-easy-one.html)

velohead66 13 May 2003 08:02 AM

I have a set of macros where...

Macro X calls a set of other macros, say Macro A, then Macro B and then
Macro C

Macro B is a Do / Loop macro, and ends with the command
If z > 20 Then End

Independently Macro B runs nicely, and independently so does Macro C.
However if you call Macro B, then straight away, Macro C, then Macro C
does
not run.
I guess the ending in Macro B is not ideal.

Any ideas on a better way to end, keeping it simple please ??!!




If you want the full code here it is.....

Sub run_all()
Call create_start_time
Call F2_edit_spec
Call create_finish_time
End Sub

Sub create_start_time()
Dim A As Date
'variable A = start clock
A = Now
Range("D2").Select
ActiveCell.Value = A
End Sub

Sub F2_edit_spec()
Range("F1").Select
Do
x = ActiveCell.Value
ActiveCell.Value = x
ActiveCell.Offset(1, 0).Select
z = ActiveCell.Row
If z > 20 Then End
Loop
End Sub

Sub create_finish_time()
Dim B As Date
'variable B = stop clock
B = Now
Range("D3").Select
ActiveCell.Value = B
End Sub

ramdor 13 May 2003 09:47 AM

Change the End in the loop for an Exit Sub (if somethingorother>number then Exit Sub). The loop could be nicer ;) but it should work with an Exit Sub.

Cheers,

Richie.

ramdor 13 May 2003 10:00 AM

Er, change it for an Exit Loop *hits head*

Richie.

dsmith 13 May 2003 10:33 AM

is that not "exit do" ?
Scooby for sale

[Edited by dsmith - 5/13/2003 10:35:31 AM]

ramdor 13 May 2003 02:57 PM

lmao yep it is :D *hits head again*

Richie.

velohead66 13 May 2003 07:41 PM

So instead of
If z > 20 Then End

use
If z > 20 Then Exit Do

??

[Edited by velohead66 - 5/13/2003 7:42:17 PM]

ramdor 13 May 2003 07:53 PM

yep :D

Richie.

velohead66 14 May 2003 09:31 AM

Tried it at work today, but used "Then Exit Sub" by mistake (poor memory).

It actually worked like a dream.

Sound !! Ta.


All times are GMT +1. The time now is 11:50 AM.


© 2024 MH Sub I, LLC dba Internet Brands