×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

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!
  • Students Click Here

*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

Absolute & Relative References (Excel 97 Macro help, please)

Absolute & Relative References (Excel 97 Macro help, please)

Absolute & Relative References (Excel 97 Macro help, please)

(OP)
In programming a macro, I would like to have an ABSOLUTE column reference, with a REALITIVE row.

   Example,

   I have 4 column locations I want to go (ie. C,Z,BB,CD). I want to make 4 seperate macros to go to the 4 seperate locations, with the following
   condiditions:

   a) I want to mantain my row position (ie. if the ActiveCell is "C11" and I run the "Z" macro, I want my final resting point to be "Z11"

   b) I want to be able to run the 4 macros in ANY order (This is the part I am having trouble with)


   One possible solution I had was if there were some command (within VB) that would sense where the ActiveCell was and be able to return a
   row/column value. I could then use these values in a formula that would end up using the Scroll to move the screen accordingly command.

   I am really in a jam on this, so I would appreciate any help or advice that you could provide.

RE: Absolute & Relative References (Excel 97 Macro help, please)

I think it's not so big a problem. I only wonder if you are programming in VB or you are programming in Excel using VB for Applications. Because if you're programming in VBA then there is an easy solution:

ActiveCell.Address wil give you the absolute adress of the highlighted cell.

To get the Row or the Column simply change Address in to Row or Column.

The return types of the Adress function is Range. This is just a string. For the Row and Coumn function the return type is a LongInt.

For example the highlighted cell is C11. ActiveCell.Address would return "$C$11", while ActiveCell.Row would give the number 11.

Now I think it's not so hard to select the right column on the right row.

Good luck!

Jonathan

RE: Absolute & Relative References (Excel 97 Macro help, please)

Cactus13 has explained it very well. I'll just add something on how the macros should be organised:

Say we have the following Macros: MacroC, MacroZ, MacroBB, MacroCD - the names can be anything - I've just named them so their target column would be obvious. You'd write the code something like this:

In the Declaration Section of the module, put the statement:
Dim TargetCell as Range

Then write the macros:

Sub MacroC
  Set TargetCell=Activesheet.Cells(Activecell.row,Columns("C:C").Column)
Do what u want with TargetCell in the statements that follow...
End Sub


Sub MacroZ
  Set TargetCell=ActiveSheet.Cells(ActiveCell.row,Columns("Z:Z").Column)
Do what u want with TargetCell in the statements that follow...
End Sub

and so on...

Note that there's really no need to refer to the columns as "C:C" or "Z:Z" - simply using "C" or "Z" will also do.

All the best...


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

eBook - Integrating the Engineering Ecosystem
Aras Innovator provides multiple options for integrating data between systems, depending on the scenario. Utilizing the right approach to meet specific business requirements is vital. These needs range from authoring tools, federating data from various and dissimilar databases, and triggering processes and workflows. Download Now
Research Report - Simulation-Driven Design for SOLIDWORKS Users
In this engineering.com research report, we discuss the rising role of simulation and the paradigm shift commonly called the democratization of simulation. In particular, we focus on how SOLIDWORKS users can take advantage of simulation-driven design through two analysis tools: SOLIDWORKS Simulation and 3DEXPERIENCE WORKS. Download Now
White Paper - Industry 4.0 and the Future of Engineering Education
With industries becoming more automated, more tech-driven and more complex, engineers need to keep their skills and knowledge up to date in order to stay on top of this wave—and to be prepared for the Industry 4.0 future. The University of Cincinnati offers two online Master of Engineering degree programs designed specifically for practicing engineers. Download Now
eBook - The Design Gridlock Manifesto
In this eBook, you’ll learn 6 ways old CAD technology slows your company down and hear how design teams have put those problems to rest. “The Design Gridlock Manifesto” shares first-hand modern CAD experiences from 15 companies around the world. 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