Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to address adjacent cells in 123 classic macros 1

Status
Not open for further replies.

jimbackus

Technical User
Jul 2, 2002
10
GB
I know about relative vs absolute addressing, but I want to test the values in two adjacent cells in a row in a macro that I've chosen to write using classic 123 macros. Is there a way of saying look in the cell to the right of the current cell?

For example:
{if (@cellpointer("contents")=3)#and#(@cell("contents",g14)>28)}{right 2}{cell-enter "Delete"}{left 2}

This shows that I want to test a value in the current cell and the value in the cell to the right, but this example uses a fixed address. So if the macro works donw a number of rows it will always access the same cell for the second IF statement. I want it to refer to the cell on the same row as the current one.

No doubt there is a function to achieve this but I haven't spotted it yet. I had wondered if I could use the value from the "col" attribute of @CELL or @CELLPOINTER but again haven't found the reverse function.

TIA

Jim
 
Jim,

Here's a solution for you... :)

{SELECT-RANGE-RELATIVE 1,0}{EDIT-COPY}{EDIT-PASTE-SPECIAL val1,"cell-contents"}{ESC}
{IF val1=3#AND#val2>28}{R 2}Delete~{L 2}
{D}
{IF @CELLPOINTER("type")="b"}{U}{END}{U}{QUIT}
{BRANCH start}

Before running this macro, you'll first need to create the following range names (used in the macro)...

val1, val2 - assign these names to two adjacent cells anywhere in the file (They can be "out of the way" on a separate sheet if you like).

start - assign this name to the first row of the macro.

I hope this helps. Please advise as to how you make out.

Regards,

Dale Watson nd.watson@shaw.ca
 
Jim
If you replace the cell reference G14 with the following @ function it will track the row No. whilst retaining worksheet and column locations. Check the help file for the exact specs.

@COORD(1,6,@CELLPOINTER("row"),8).


Toolman59
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top