Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formula pasting is not working


I have inserted the following formula and I am getting this error:

Runtime error 1004
Application-defined or object-defined error

Range(Cells(EndRow + 1, 7), Cells(EndRow + 1, 4)).FormulaR1C1 =
"=IF(RC[-2]RC[-1],'W')"


I am trying to paste this on a cell, returning the letter W if the cell
offset by 2 is greater than the cell offset by 1.

In fact I want to add another condition in the same code where I want the
code to return the letter L if the cell offset by 2 is smaller than the
cell offset by 1 plus to return the letter D if the cell offset by 2 equals
the cell offset by 1.

Example

A B C
D E F
1 01-Dec-03 Arsenal Coventry 4 1
W
2 01-Dec-03 Man Utd. Southampton 1 3
L
3 01-Dec-03 Tottenham Chelsea 2 2
D


Thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formula pasting is not working

This is a better looking table !

A B C D E F
1 01-Dec-03 Arsenal Coventry 4 1 W
2 01-Dec-03 Man Utd. So'ton 1 3 L
3 01-Dec-03 Tottenham Chelsea 2 2 D


Thanks




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Formula pasting is not working

I think you need something like this:

Range(Cells(EndRow + 1, 4), Cells(EndRow + 1, 7)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"","""")"

However, this actually puts the formula under the rows.

Maybe what you actually need is something like this:

Dim EndRow As Long
Dim EndCol As Long
EndRow = Range("A65536").End(xlUp).Row
EndCol = Range("IV1").End(xlToLeft).Column
Range(Cells(1, EndCol + 1), Cells(EndRow, EndCol + 1)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"","""")"

Hence the final solution would be:

Dim EndRow As Long
Dim EndCol As Long
EndRow = Range("A65536").End(xlUp).Row
EndCol = Range("IV1").End(xlToLeft).Column
Range(Cells(1, EndCol + 1), Cells(EndRow, EndCol + 1)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"",IF(RC[-2]<RC[-1],""L"",""D""))"


Regards

Trevor


"Majeed" wrote in message
...

I have inserted the following formula and I am getting this error:

Runtime error 1004
Application-defined or object-defined error

Range(Cells(EndRow + 1, 7), Cells(EndRow + 1, 4)).FormulaR1C1 =
"=IF(RC[-2]RC[-1],'W')"


I am trying to paste this on a cell, returning the letter W if the cell
offset by 2 is greater than the cell offset by 1.

In fact I want to add another condition in the same code where I want the
code to return the letter L if the cell offset by 2 is smaller than the
cell offset by 1 plus to return the letter D if the cell offset by 2

equals
the cell offset by 1.

Example

A B C
D E F
1 01-Dec-03 Arsenal Coventry 4

1
W
2 01-Dec-03 Man Utd. Southampton 1 3
L
3 01-Dec-03 Tottenham Chelsea 2 2
D


Thanks




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Formula pasting is not working

Thanks Trevor, it works perecftly now

Cheers and a happy new year to you.

Majeed



"Trevor Shuttleworth" wrote in message
...
I think you need something like this:

Range(Cells(EndRow + 1, 4), Cells(EndRow + 1, 7)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"","""")"

However, this actually puts the formula under the rows.

Maybe what you actually need is something like this:

Dim EndRow As Long
Dim EndCol As Long
EndRow = Range("A65536").End(xlUp).Row
EndCol = Range("IV1").End(xlToLeft).Column
Range(Cells(1, EndCol + 1), Cells(EndRow, EndCol + 1)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"","""")"

Hence the final solution would be:

Dim EndRow As Long
Dim EndCol As Long
EndRow = Range("A65536").End(xlUp).Row
EndCol = Range("IV1").End(xlToLeft).Column
Range(Cells(1, EndCol + 1), Cells(EndRow, EndCol + 1)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"",IF(RC[-2]<RC[-1],""L"",""D""))"


Regards

Trevor


"Majeed" wrote in message
...

I have inserted the following formula and I am getting this error:

Runtime error 1004
Application-defined or object-defined error

Range(Cells(EndRow + 1, 7), Cells(EndRow + 1, 4)).FormulaR1C1 =
"=IF(RC[-2]RC[-1],'W')"


I am trying to paste this on a cell, returning the letter W if the cell
offset by 2 is greater than the cell offset by 1.

In fact I want to add another condition in the same code where I want

the
code to return the letter L if the cell offset by 2 is smaller than the
cell offset by 1 plus to return the letter D if the cell offset by 2

equals
the cell offset by 1.

Example

A B C
D E F
1 01-Dec-03 Arsenal Coventry 4

1
W
2 01-Dec-03 Man Utd. Southampton 1 3
L
3 01-Dec-03 Tottenham Chelsea 2

2
D


Thanks






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,089
Default Formula pasting is not working

Majeed

Nice to know that your problem is solved

And all the best for the New Year to you too.

Trevor


"Majeed" wrote in message
...
Thanks Trevor, it works perecftly now

Cheers and a happy new year to you.

Majeed



"Trevor Shuttleworth" wrote in message
...
I think you need something like this:

Range(Cells(EndRow + 1, 4), Cells(EndRow + 1, 7)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"","""")"

However, this actually puts the formula under the rows.

Maybe what you actually need is something like this:

Dim EndRow As Long
Dim EndCol As Long
EndRow = Range("A65536").End(xlUp).Row
EndCol = Range("IV1").End(xlToLeft).Column
Range(Cells(1, EndCol + 1), Cells(EndRow, EndCol + 1)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"","""")"

Hence the final solution would be:

Dim EndRow As Long
Dim EndCol As Long
EndRow = Range("A65536").End(xlUp).Row
EndCol = Range("IV1").End(xlToLeft).Column
Range(Cells(1, EndCol + 1), Cells(EndRow, EndCol + 1)).FormulaR1C1 = _
"=IF(RC[-2]RC[-1],""W"",IF(RC[-2]<RC[-1],""L"",""D""))"


Regards

Trevor


"Majeed" wrote in message
...

I have inserted the following formula and I am getting this error:

Runtime error 1004
Application-defined or object-defined error

Range(Cells(EndRow + 1, 7), Cells(EndRow + 1, 4)).FormulaR1C1 =
"=IF(RC[-2]RC[-1],'W')"


I am trying to paste this on a cell, returning the letter W if the

cell
offset by 2 is greater than the cell offset by 1.

In fact I want to add another condition in the same code where I want

the
code to return the letter L if the cell offset by 2 is smaller than

the
cell offset by 1 plus to return the letter D if the cell offset by 2

equals
the cell offset by 1.

Example

A B C
D E F
1 01-Dec-03 Arsenal Coventry 4

1
W
2 01-Dec-03 Man Utd. Southampton 1 3
L
3 01-Dec-03 Tottenham Chelsea 2

2
D


Thanks








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
Excel 2002. Pasting into cell has stopped working. Jeremy Flowers Excel Discussion (Misc queries) 0 December 4th 08 10:14 AM
IF Statement not working after pasting data Dozaec Excel Discussion (Misc queries) 1 February 12th 08 05:14 PM
Pasting from another workbook was working and now is not Katie Excel Discussion (Misc queries) 0 October 22nd 07 04:55 PM
Copy and pasting ref cells is not working Will Excel Discussion (Misc queries) 2 November 30th 06 10:07 PM
Pasting on Filtered Data Sheets without pasting onto hidden cells CCSMCA Excel Discussion (Misc queries) 1 August 28th 05 01:22 PM


All times are GMT +1. The time now is 01:36 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"