Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default IF-THEN to skip portion of macro

I"ve been designing spreadsheets for about 20 yrs, but just started VBA
this last summer. I used to write macros in the older versions of Lotus
(pre graphic interface). The problem I have now was easy to overcome
back then.

I'm sure I'm not structuring my code efficiently, but things are
working ok for now. I'll have to go back later when I learn more, and
re-do what I'm writing now, to make it more efficient. That's part of
the process for me.

I have a file where we add new lines (records), and delete lines, each
day. We move the lines to be deleted to another folder within this
file. We sort the new list by one of the columns, format all the cells
to look nice and pretty.Then we print the new list.

What I have now is a giant macro initiated by a button the user clicks
after entering in the new records at the bottom of the list, and making
an entry in a column for each line to be moved.

I'll outline how the macro flows:
*Move records to be deleted
*Sort the list, and format cells.
*Print report.

I am sure I should want these sections seperated. But, as I've learned
VBA on the run, I just entered coding in this giant macro.

What I have done so far today is to start another sub at the bottom of
this giant macro, and I named it
Private Sub SkipMove()

I have a cell that counts the number of lines that are shown to be
moved. I have named that cell "Deleted_Today".

My question is: Can I use an IF-THEN statement, right when the user
clicks the button, that will look at the value of "Deleted_Today", and
if it's 0, then move on to the the sub SkipMove ?

In the old days of Lotus macros, I used to use a Branch statement to do
such things. Is the way I described above, creating another sub, the
correct way of "branching" the instructions?
If so, can somone help me with a way to write the IF-THEN code?
Something like this, in English:
IF "Deleted_Today" = 0, then go to SkipMove, else continue the macro.

Thanks to all who take the time to respond. This is a great forum, and
I've learn alot reading the questions/answers from others.

excelnut

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default IF-THEN to skip portion of macro

Do not branch - it is heresy :-))

If Range("Deleted_Today") = 0 Then
SkipMove
Else
' ... do the rest
End If

You could also put teh rest in a separate sub, and call that on the Else
condition, thereby having a flow control master sub.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"excelnut1954" wrote in message
ups.com...
I"ve been designing spreadsheets for about 20 yrs, but just started VBA
this last summer. I used to write macros in the older versions of Lotus
(pre graphic interface). The problem I have now was easy to overcome
back then.

I'm sure I'm not structuring my code efficiently, but things are
working ok for now. I'll have to go back later when I learn more, and
re-do what I'm writing now, to make it more efficient. That's part of
the process for me.

I have a file where we add new lines (records), and delete lines, each
day. We move the lines to be deleted to another folder within this
file. We sort the new list by one of the columns, format all the cells
to look nice and pretty.Then we print the new list.

What I have now is a giant macro initiated by a button the user clicks
after entering in the new records at the bottom of the list, and making
an entry in a column for each line to be moved.

I'll outline how the macro flows:
*Move records to be deleted
*Sort the list, and format cells.
*Print report.

I am sure I should want these sections seperated. But, as I've learned
VBA on the run, I just entered coding in this giant macro.

What I have done so far today is to start another sub at the bottom of
this giant macro, and I named it
Private Sub SkipMove()

I have a cell that counts the number of lines that are shown to be
moved. I have named that cell "Deleted_Today".

My question is: Can I use an IF-THEN statement, right when the user
clicks the button, that will look at the value of "Deleted_Today", and
if it's 0, then move on to the the sub SkipMove ?

In the old days of Lotus macros, I used to use a Branch statement to do
such things. Is the way I described above, creating another sub, the
correct way of "branching" the instructions?
If so, can somone help me with a way to write the IF-THEN code?
Something like this, in English:
IF "Deleted_Today" = 0, then go to SkipMove, else continue the macro.

Thanks to all who take the time to respond. This is a great forum, and
I've learn alot reading the questions/answers from others.

excelnut



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
Skip a Macro Vick Excel Discussion (Misc queries) 2 December 22nd 09 05:06 PM
Macro Skip workbook [email protected] Excel Worksheet Functions 1 February 7th 08 04:24 PM
Macro Skip workbook [email protected] Excel Worksheet Functions 0 February 7th 08 03:54 PM
Sheets Skip Macro NICK Excel Discussion (Misc queries) 2 February 11th 05 07:16 AM
How to skip in a macro Bob Phillips[_6_] Excel Programming 1 February 9th 04 05:56 PM


All times are GMT +1. The time now is 01:10 AM.

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

About Us

"It's about Microsoft Excel"