×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Are you an
Engineering professional?
Join Eng-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
• Keyword Search
Favorite Forums
• Automated Signatures
• 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.

# 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:

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.

#### Resources

eBook - Manufacturing the Cars of Tomorrow
In this ebook, we'll explore how additive manufacturing is going to transform the way cars are made. This includes commentary from thought leaders such as Ford's CTO, Ken Washington, Customer case studies of ways 3D printing is being used today, and a variety of part examples where 3D printing is already impacting how automobiles are made. Download Now
White Paper - Smart Manufacturing for Semiconductor
New technologies and approaches present great opportunities for semiconductor manufacturers to achieve high levels of innovation, yield and improvement. This white paper explores some of these cutting-edge technologies and how they can be applied effectively in the semiconductor industry. Read about how Smart Manufacturing is transforming the semiconductor industry. Download Now
White Paper - Analysis and Simulation in Aircraft Structure Certification
Organizations using simulation and analysis tools effectively see the benefits in their ability to achieve certification faster and with drastically less total cost than those who do not maximize these tools. Read this White Paper to learn about how digital tools such as analysis and simulation help in aircraft structure certification. 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:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!