Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

VB for excel - easy one

Thread Tools
 
Search this Thread
 
Old 13 May 2003, 08:02 AM
  #1  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Question

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
Old 13 May 2003, 09:47 AM
  #2  
ramdor
Scooby Regular
iTrader: (2)
 
ramdor's Avatar
 
Join Date: Feb 2003
Posts: 700
Likes: 0
Received 0 Likes on 0 Posts
Post

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.
Old 13 May 2003, 10:00 AM
  #3  
ramdor
Scooby Regular
iTrader: (2)
 
ramdor's Avatar
 
Join Date: Feb 2003
Posts: 700
Likes: 0
Received 0 Likes on 0 Posts
Post

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

Richie.
Old 13 May 2003, 10:33 AM
  #4  
dsmith
Scooby Regular
 
dsmith's Avatar
 
Join Date: Mar 1999
Posts: 4,518
Likes: 0
Received 0 Likes on 0 Posts
Post

is that not "exit do" ?
Scooby for sale

[Edited by dsmith - 5/13/2003 10:35:31 AM]
Old 13 May 2003, 02:57 PM
  #5  
ramdor
Scooby Regular
iTrader: (2)
 
ramdor's Avatar
 
Join Date: Feb 2003
Posts: 700
Likes: 0
Received 0 Likes on 0 Posts
Post

lmao yep it is *hits head again*

Richie.
Old 13 May 2003, 07:41 PM
  #6  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Question

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]
Old 13 May 2003, 07:53 PM
  #7  
ramdor
Scooby Regular
iTrader: (2)
 
ramdor's Avatar
 
Join Date: Feb 2003
Posts: 700
Likes: 0
Received 0 Likes on 0 Posts
Post

yep

Richie.
Old 14 May 2003, 09:31 AM
  #8  
velohead66
Scooby Regular
Thread Starter
 
velohead66's Avatar
 
Join Date: Oct 2002
Location: ex UK [SE], now Sunshine State [QLD,AUS]
Posts: 565
Likes: 0
Received 1 Like on 1 Post
Cool

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

It actually worked like a dream.

Sound !! Ta.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
leg200
Subaru Parts
5
07 October 2015 07:31 AM
has-scooby
Subaru Parts
4
06 October 2015 03:47 PM
bluebullet29
General Technical
9
05 October 2015 02:17 PM



Quick Reply: VB for excel - easy one



All times are GMT +1. The time now is 04:29 AM.