R1C1 style reference as Condition

  • Thread starter Thread starter aca
  • Start date Start date
A

aca

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


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
 
Thank you David, but your solution is limited to the exemple I gave.
Instead, I am looking for something with general functionnality
like
 
msgbox activesheet.cells(activecell.row-1,"B").value

maybe...
 
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
 
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 said:
msgbox activesheet.cells(activecell.row-1,"B").value

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

Dave "I'm not Kreskin" Peterson



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

Wow Dave. Need to sharpen those mind reading skills! <LOL>
 
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:
 
I'm sure I join the others in saying that we're glad you got your problem
resolved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top