Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Referencing a fixed cell in VBA using an IF statement

Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row of
cells.

I'm writing some code to put a formula into a cell using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up as
a variable but that doesn't work either. The code below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Referencing a fixed cell in VBA using an IF statement

Hi Neill,

I think this is what you want

ActiveCell.FormulaR1C1 = "=IF(R1C3=""h"",R1C19,""K"")"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Neil Crawford" wrote in message
...
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row of
cells.

I'm writing some code to put a formula into a cell using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up as
a variable but that doesn't work either. The code below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 136
Default Referencing a fixed cell in VBA using an IF statement

ActiveCell.FormulaR1C1 = "=IF(RC[-4]= ""h"",R1C19,""K"")"

Neil Crawford wrote:
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row of
cells.

I'm writing some code to put a formula into a cell using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up as
a variable but that doesn't work either. The code below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Referencing a fixed cell in VBA using an IF statement

ActiveCell.FormulaR1C1 = "=IF(RC[-4]= ""h"",$s$1,""K"")"

Check it from the immediate window:

? "=IF(RC[-4]=""h"",$s$1,""K"")"
=IF(RC[-4]="h",$s$1,"K")

--
Regards,
Tom Ogilvy


"Neil Crawford" wrote in message
...
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row of
cells.

I'm writing some code to put a formula into a cell using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up as
a variable but that doesn't work either. The code below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Referencing a fixed cell in VBA using an IF statement

Whoops, mixed reference types:

ActiveCell.FormulaR1C1 = "=IF(RC[-4]= ""h"",R1C19,""K"")"

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
ActiveCell.FormulaR1C1 = "=IF(RC[-4]= ""h"",$s$1,""K"")"

Check it from the immediate window:

? "=IF(RC[-4]=""h"",$s$1,""K"")"
=IF(RC[-4]="h",$s$1,"K")

--
Regards,
Tom Ogilvy


"Neil Crawford" wrote in message
...
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row of
cells.

I'm writing some code to put a formula into a cell using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up as
a variable but that doesn't work either. The code below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Referencing a fixed cell in VBA using an IF statement

Sorry for some reason I read the if as $C$1, should be

ActiveCell.FormulaR1C1 = "=IF(RC[-4]=""h"",R1C19,""K"")"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote in message
...
Hi Neill,

I think this is what you want

ActiveCell.FormulaR1C1 = "=IF(R1C3=""h"",R1C19,""K"")"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Neil Crawford" wrote in message
...
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row of
cells.

I'm writing some code to put a formula into a cell using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up as
a variable but that doesn't work either. The code below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil





  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Referencing a fixed cell in VBA using an IF statement

Tom,

thanks, will give it a go,

Neil
-----Original Message-----
Whoops, mixed reference types:

ActiveCell.FormulaR1C1 = "=IF(RC[-4]= ""h"",R1C19,""K"")"

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
ActiveCell.FormulaR1C1 = "=IF(RC[-4]

= ""h"",$s$1,""K"")"

Check it from the immediate window:

? "=IF(RC[-4]=""h"",$s$1,""K"")"
=IF(RC[-4]="h",$s$1,"K")

--
Regards,
Tom Ogilvy


"Neil Crawford"

wrote in message
...
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a

row of
cells.

I'm writing some code to put a formula into a cell

using
an If statement. I want to pick up a value from a

cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it

up as
a variable but that doesn't work either. The code

below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]

= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil





.

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Referencing a fixed cell in VBA using an IF statement

Bob,

thanks, will give it a go,

Neil
-----Original Message-----
Sorry for some reason I read the if as $C$1, should be

ActiveCell.FormulaR1C1 = "=IF(RC[-4]=""h"",R1C19,""K"")"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Bob Phillips" wrote

in message
...
Hi Neill,

I think this is what you want

ActiveCell.FormulaR1C1 = "=IF(R1C3=""h"",R1C19,""K"")"


--

HTH

Bob Phillips
... looking out across Poole Harbour to the

Purbecks
(remove nothere from the email address if mailing

direct)

"Neil Crawford"

wrote in message
...
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a

row of
cells.

I'm writing some code to put a formula into a cell

using
an If statement. I want to pick up a value from a

cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it

up as
a variable but that doesn't work either. The code

below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]

= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil





.

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Referencing a fixed cell in VBA using an IF statement

J,

thanks,

Neil
-----Original Message-----
ActiveCell.FormulaR1C1 = "=IF(RC[-4]= ""h"",R1C19,""K"")"

Neil Crawford wrote:
Dear all,

I'd be grateful for some advice on how to reference a
fixed cell in a formula that I wish to copy down a row

of
cells.

I'm writing some code to put a formula into a cell

using
an If statement. I want to pick up a value from a cell
that is anchored ($S$1) but I can't seem to get it
correct in the formula. I've also tried setting it up

as
a variable but that doesn't work either. The code

below
works except for the "=$S$1" part.

ActiveCell.FormulaR1C1 = "=IF((RC[-4]

= ""h,"=$s$1",""K"")"

Any guidance would be gratefully received!

thanks,

Neil

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
referencing text in an IF statement Michelle Thompson Excel Worksheet Functions 1 December 4th 09 05:33 PM
Fixed/Locked cell referencing tpdigg Excel Discussion (Misc queries) 6 September 15th 09 01:09 PM
IF Statement: cell referencing Mike Excel Worksheet Functions 5 November 5th 07 02:24 PM
referencing cells including an IF statement??? Helpme Excel Worksheet Functions 0 December 28th 06 09:57 PM
drawdown at fixed rate over set period from investment at fixed % jamook New Users to Excel 1 November 28th 05 10:53 PM


All times are GMT +1. The time now is 10:21 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"