Restoring Line Numbers

G

Guest

Several of you have helped me in the past with code, for that I am very
grateful for all of your help. However, this VBA is still very hard for me
to do on my own, with out a lot of help. Now if I could restore the line
numbers to VBA, then I know that I could do my own coding, or can I by
recording a Macro, see how to write a statement with the If…End if, I haven’t
been able to figure that out as of yet.

Is there a way to restore those annoying line numbers?

Steve
 
R

Rowan Drummond

Hi Steve

Do you mean line numbers in the VBE? To do this you would need a COM
addin called MZTools. www.mztools.com. It is free and has a lot of other
helpful features as well as line numbering your code.

You can't record If statements but have a look in visual basic help.
They are pretty well described.

Hope this helps
Rowan
 
G

Guest

Thanks Rown for you reply, but I must be a complete idiot, becasue those
instructions, confuse me more then help me. O well

Steve
 
R

Rowan Drummond

Hi Steve

It could just be me that is confused <g>. What line numbers are you
wanting to restore?

Regards
Rowan
 
G

Guest

Hi Rown,

I'm working with a code that saves open workbooks. My problem is there is
one workbook that I don't want to save, everytime I try to figure out to use
a if statement, it just dosen't work. It is only looking at the one file I
don't need to save. It is not even getting to the others at all.

Now if programming the old fashion way by using line numbers in my code I
know how to get around this problem.

Example:

10 If A=1 then
20 Goto 50
30 Else
40 Save Activeworkbook.name ("insert workbook name here")
50 Endif

My problem is step 20, I can't figure out to have system check all open
workbooks, and save them all but one.

Steve-the frustrated man
 
C

Chip Pearson

Using Goto statements is very poor coding practice and should not
be used. If I understand your question, you can use code like the
following:

Dim WB As Workbook
For Each WB In Workbooks
If WB.Name <> "TheOneYouDoNotWantToSave.xls" Then
WB.Save
End If
Next WB


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
 
G

Guest

Chip thanks for the reply, but you see I'm a very old gentleman and that the
way I use t oprogram. Just now trying to get my hands around this VBA coding
and it is very hard for me to get it.

But reading your coding I think that I was forgetting a line, and you just
help me out.

Thanks again,

Steve
 
J

John Coleman

caldog said:
Chip thanks for the reply, but you see I'm a very old gentleman and that the
way I use t oprogram. Just now trying to get my hands around this VBA coding
and it is very hard for me to get it.

Hi,
The code fragment you gave brought back memories of programming the
TRS-80 (which my father bought when I was still a high-school student
in the 70s). For years I got away from programming, until I started
writing Excel macros about 5 years ago. I found Walkenbach's small book
"Excel VBA for Dummies" a useful tool for making the transition from
old-style Basic to new-style Basic. After I got through that I was
ready to tackle more ambitious books.

-John Coleman
 
T

Tom Ogilvy

Sub SaveBooks()
10 B = Application.Workbooks.Count
20 A = 1
30 Application.Workbooks(A).Activate
40 If UCase(ActiveWorkbook.Name) = "ABCD.XLS" _
Then GoTo 60
50 ActiveWorkbook.Save
60 A = A + 1
70 If A <= B Then GoTo 30

End Sub

worked for me.
 
G

Guest

Thanks Tom what I was looking for in code. Also by looking at Chip's code,
the light finally came on, I was missing the for... next loop. Once I got
that coded, everthing is working. Not perfect but usable.

Thanks again for everybody's help.

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top