+ Reply to Thread
Results 1 to 10 of 10

R1C1 style reference as Condition

  1. #1
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    236

    R1C1 style reference as Condition

    In a macro,
    What is the syntax for a conditional line,
    the condition being the contents of a cell referred to with the style RC[-1 ] (same Row as the current cell, but Column one above)?

    Something like
    ------------------------------------------------
    If ??????? RC[-1 ] ??? = ""Then
    ActiveCell = "The cell above-left is empty"
    End If
    ------------------------------------------------
    What should the first half of my 1st line be?

    I'll feel very grateful to anyone who can help.
    ACA

  2. #2
    Dave Peterson
    Guest

    Re: R1C1 style reference as Condition

    If you want the cell above the activecell:
    if activecell.offset(-1,0).value = "" then

    if you want one column to the left:
    if activecell.offset(0,-1).value = "" then

    If you want on column to the left and one row up:
    if activecell.offset(-1,-1).value = "" then



    aca wrote:
    >
    > In a macro,
    > What is the syntax for a conditional line,
    > the condition being the contents of a cell referred to with the style
    > RC[-1 ] (same Row as the current cell, but Column one above)?
    >
    > Something like
    > ------------------------------------------------
    > If ??????? RC[-1 ] ??? = ""Then
    > ActiveCell = "The cell above-left is empty"
    > End If
    > ------------------------------------------------
    > What should the first half of my 1st line be?
    >
    > I'll feel very grateful to anyone who can help.
    > ACA
    >
    > --
    > aca
    > ------------------------------------------------------------------------
    > aca's Profile: http://www.excelforum.com/member.php...o&userid=25933
    > View this thread: http://www.excelforum.com/showthread...hreadid=539539


    --

    Dave Peterson

  3. #3
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    236
    Thank you David, but your solution is limited to the exemple I gave.
    Instead, I am looking for something with general functionnality like
    ------------------------------------
    If ????? C2R[-1]??? ="" Then
    .......
    ------------------------------------
    If the cell in the Row above, but always in Column B, no matter which column the active cell is in.
    ACA

  4. #4
    Dave Peterson
    Guest

    Re: R1C1 style reference as Condition

    msgbox activesheet.cells(activecell.row-1,"B").value

    maybe...

    aca wrote:
    >
    > Thank you David, but your solution is limited to the exemple I gave.
    > Instead, I am looking for something with general functionnality
    > like
    > ------------------------------------
    > If ????? C2R[-1]??? ="" Then
    > ......
    > ------------------------------------
    > If the cell in the Row above, but always in Column B, no matter which
    > column the active cell is in.
    > ACA
    >
    > --
    > aca
    > ------------------------------------------------------------------------
    > aca's Profile: http://www.excelforum.com/member.php...o&userid=25933
    > View this thread: http://www.excelforum.com/showthread...hreadid=539539


    --

    Dave Peterson

  5. #5
    Tim Williams
    Guest

    Re: R1C1 style reference as Condition

    assuming c is the starting (single-cell) range:

    '***********************************
    if c.parent.cells(c.row-1, 2) = "whatever" then
    'do stuff
    end if
    '***********************************

    Should test that c.row > 2


    Tim

    "aca" <[email protected]> wrote in message news:[email protected]...
    >
    > Thank you David, but your solution is limited to the exemple I gave.
    > Instead, I am looking for something with general functionnality
    > like
    > ------------------------------------
    > If ????? C2R[-1]??? ="" Then
    > ......
    > ------------------------------------
    > If the cell in the Row above, but always in Column B, no matter which
    > column the active cell is in.
    > ACA
    >
    >
    > --
    > aca
    > ------------------------------------------------------------------------
    > aca's Profile: http://www.excelforum.com/member.php...o&userid=25933
    > View this thread: http://www.excelforum.com/showthread...hreadid=539539
    >




  6. #6
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    236
    Thanks A Lot, Tim:
    You've Been Great Help.
    Aca

  7. #7
    Tom Ogilvy
    Guest

    Re: R1C1 style reference as Condition

    > Thank you David, but your solution is limited to the exemple I gave.

    Wow Dave. Need to sharpen those mind reading skills! <LOL>

    --
    Regards,
    Tom Ogilvy

    "Dave Peterson" <[email protected]> wrote in message
    news:[email protected]...
    > msgbox activesheet.cells(activecell.row-1,"B").value
    >
    > maybe...
    >
    > aca wrote:
    > >
    > > Thank you David, but your solution is limited to the exemple I gave.
    > > Instead, I am looking for something with general functionnality
    > > like
    > > ------------------------------------
    > > If ????? C2R[-1]??? ="" Then
    > > ......
    > > ------------------------------------
    > > If the cell in the Row above, but always in Column B, no matter which
    > > column the active cell is in.
    > > ACA
    > >
    > > --
    > > aca
    > > ------------------------------------------------------------------------
    > > aca's Profile:

    http://www.excelforum.com/member.php...o&userid=25933
    > > View this thread:

    http://www.excelforum.com/showthread...hreadid=539539
    >
    > --
    >
    > Dave Peterson




  8. #8
    Dave Peterson
    Guest

    Re: R1C1 style reference as Condition

    But I will achieve total consciousness on my deathbed.
    So I got that going for me.

    Dave "I'm not Kreskin" Peterson



    Tom Ogilvy wrote:
    >
    > > Thank you David, but your solution is limited to the exemple I gave.

    >
    > Wow Dave. Need to sharpen those mind reading skills! <LOL>
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    > "Dave Peterson" <[email protected]> wrote in message
    > news:[email protected]...
    > > msgbox activesheet.cells(activecell.row-1,"B").value
    > >
    > > maybe...
    > >
    > > aca wrote:
    > > >
    > > > Thank you David, but your solution is limited to the exemple I gave.
    > > > Instead, I am looking for something with general functionnality
    > > > like
    > > > ------------------------------------
    > > > If ????? C2R[-1]??? ="" Then
    > > > ......
    > > > ------------------------------------
    > > > If the cell in the Row above, but always in Column B, no matter which
    > > > column the active cell is in.
    > > > ACA
    > > >
    > > > --
    > > > aca
    > > > ------------------------------------------------------------------------
    > > > aca's Profile:

    > http://www.excelforum.com/member.php...o&userid=25933
    > > > View this thread:

    > http://www.excelforum.com/showthread...hreadid=539539
    > >
    > > --
    > >
    > > Dave Peterson


    --

    Dave Peterson

  9. #9
    Forum Contributor
    Join Date
    08-04-2005
    Location
    Madrid, Spain
    MS-Off Ver
    2010
    Posts
    236
    Dave Peterson, Tim Williams, Tom Ogilvy....
    Tank you so much to all of you.
    I see my message has triggered a crossfire of friendly exchanges due to a mistake I must have made in my previous reply, thanking the wrong person. Well thankfulness is never wrong, for you all have helped me greatly.
    If you are curious to know, the solution (coming from one of you) that exactly suits my problem is this:

    ---------------------------------------------------
    If ActiveSheet.Cells(ActiveCell.Row - 1, "B").Value = "" Then
    ActiveCell = "The cell, in column B and Row above this one, is empty"
    End If
    -------------------------------------------------

    Again, my threefold thank you
    ACA

  10. #10
    Dave Peterson
    Guest

    Re: R1C1 style reference as Condition

    I'm sure I join the others in saying that we're glad you got your problem
    resolved.

    aca wrote:
    >
    > Dave Peterson, Tim Williams, Tom Ogilvy....
    > Tank you so much to all of you.
    > I see my message has triggered a crossfire of friendly exchanges due to
    > a mistake I must have made in my previous reply, thanking the wrong
    > person. Well thankfulness is never wrong, for you all have helped me
    > greatly.
    > If you are curious to know, the solution (coming from one of you)
    > that exactly suits my problem is this:
    >
    > ---------------------------------------------------
    > If ActiveSheet.Cells(ActiveCell.Row - 1, "B").Value = "" Then
    > ActiveCell = "The cell, in column B and Row above this one, is empty"
    > End If
    > -------------------------------------------------
    >
    > Again, my threefold thank you
    > ACA
    >
    > --
    > aca
    > ------------------------------------------------------------------------
    > aca's Profile: http://www.excelforum.com/member.php...o&userid=25933
    > View this thread: http://www.excelforum.com/showthread...hreadid=539539


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1