×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

What about macros
2

What about macros

What about macros

(OP)
I started to develop macros in EXCELL spreedsheets for particular aplications and soon realized that they are tricky.
I learned that you must execute macros locating (the cursor) in the sheet it is supposed to start, otherwise you woul watch it perform the operation over the wrong selection, for example.
What else is there about macros to watch out (apart from the virus issue)?

RE: What about macros

Check out "Writing Excel Macros" from O'Reilly publishing.

RE: What about macros

MACRO PERFORMING ON ACTIVE WORKSHEET

This is the default when you do not specify the kind of xls file or the workbook or the worksheet on which the macro is to operate.

If it causes problems, you may put a message box into the macro asking for varification of the active sheet.

You can even make the macro to check the xls file name or the sheet name before going on.

But as I said, for most operations, it is just great to have the macro run on the active workbook.

Compares to the Print tool that asks no questions - a bit annoying at first but very practical later.

RE: What about macros

When you write a XL macro  to do something, there are several basic things you must take care of including the sheet for which it is supposed to run:
To cite one -
If the macro is intended to work on a range and the selection is an object, it'll screech to a halt with a suitable msg if the VBA code refers to the 'Selection' object. In such cases, its a good idea to incorporate in the macro, code to identify the type of selection before the main body of the code runs.. use typename

For example, exit the procedure without doing anything
Sub XYZ()
If typename(selection)<>"Range" then Exit Sub '
Other statements...
End Sub

OR Display a helpful msg

Sub XYZ()
If typename(selection)<>"Range" then msgbox("Select a range and try again")
Other statements...
End Sub

RE: What about macros

Can somebody let me know please how can I pick a particulr value from a range against a particular value. For instance If I am using  from Menue, Data> Validation> Pick from List, and I have 2 colums in the list having particular value against a particular vriable, how can I put value against a particular variable in my required cell.
An example is :
Pipe          Actual
Nominal Dia   Inside Dia
2              2.067
2 1/2          2.469
3              3.068
I want to pick 3 and want the value 3.068 in my required cell. I shall be thankful for the help anybody can give me.

RE: What about macros

You should check out VLOOKUP or HLOOKUP in the help menu.

RE: What about macros

Use Lookup function

=LOOKUP(C1,A1:A3,B1:B3)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close