Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

I'm still new to this which might explain why I'm making such a pig's
ear of the below!

I am trying to perform an equation that divides that value in one cell
by the value in another. 'Findrange' is the range of the cell that has
the absolute value that I wish to divide by. RC[-1] is the relative
position that contains the value that I wish to have divided by the
value in the Findrange variable.
However, I simply cannot get this to work!


My code is as follows:

For i = 1 To FTDRange.Cells.Rows.Count
FTDRange.Cells(i).Value = "=rc[-1]" / findrange
i = i + 1
Next i


Any ideas???

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

Hi:

You are mixing formulas and values in the same expression. Try (untested):

FTDRange.Cells(i).Value = FTDRange.Cells(i).Offset(, -1).Value / findrange

Regards,

Vasant.

"Kobayashi" wrote in message
...
I'm still new to this which might explain why I'm making such a pig's
ear of the below!

I am trying to perform an equation that divides that value in one cell
by the value in another. 'Findrange' is the range of the cell that has
the absolute value that I wish to divide by. RC[-1] is the relative
position that contains the value that I wish to have divided by the
value in the Findrange variable.
However, I simply cannot get this to work!


My code is as follows:

For i = 1 To FTDRange.Cells.Rows.Count
FTDRange.Cells(i).Value = "=rc[-1]" / findrange
i = i + 1
Next i


Any ideas???

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

I can't combine "=rc" with addresses in the same formula. This works = "=4/"
& myaddress
But you could give your rc[-1] as an address (myaddress) and if findrange is
an address then your formula should be
= "=" & myaddress & "/" & findrange

Ole Michelsen

"Kobayashi" wrote in message
...
I'm still new to this which might explain why I'm making such a pig's
ear of the below!

I am trying to perform an equation that divides that value in one cell
by the value in another. 'Findrange' is the range of the cell that has
the absolute value that I wish to divide by. RC[-1] is the relative
position that contains the value that I wish to have divided by the
value in the Findrange variable.
However, I simply cannot get this to work!


My code is as follows:

For i = 1 To FTDRange.Cells.Rows.Count
FTDRange.Cells(i).Value = "=rc[-1]" / findrange
i = i + 1
Next i


Any ideas???

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

Kobayashi,

For i = 1 to FTDRange.Rows.Count
Cells(i, 3).Value = Cells(i, 3).Offset(0,-1)/ Range("findrange")
Next

or
For i = 1 to FTDRange.Rows.Count
Cells(i, 3).Value = Cells(i, 2)/ Range("findrange")
Next

Am a little unsure of how you are defining FTDRange.
"FTDRange.Cells" looks like a "double" reference to a range.

The code above assumes that FTDRange is a range starting in row 1 and
is in column C.

If this doesn't work. Post back and include how FTDRange is defined.
And what it is. Also need the same for findrange. Are they defined on the
worksheet or in the code. Makes a lot of difference.

Range defined in the worksheet use:
Range("myrange") = 5/2
Range("myrange").Value = ???
Range defined in code use:
Dim myrange as Range
Set myrange = Range("A1:A5")
myrange = 5/2
myrange.Value = ???
--
sb
"Kobayashi" wrote in message
...
I'm still new to this which might explain why I'm making such a pig's
ear of the below!

I am trying to perform an equation that divides that value in one cell
by the value in another. 'Findrange' is the range of the cell that has
the absolute value that I wish to divide by. RC[-1] is the relative
position that contains the value that I wish to have divided by the
value in the Findrange variable.
However, I simply cannot get this to work!


My code is as follows:

For i = 1 To FTDRange.Cells.Rows.Count
FTDRange.Cells(i).Value = "=rc[-1]" / findrange
i = i + 1
Next i


Any ideas???

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

Vasant/Ole/Steve,

Many thanks for your replies! There's quite a lot to keep me going so I
shall test and let you know how I get on?

Many thanks for taking the trouble to reply!

Regards,

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

Steve,

Here is my code. I have modified it slightly by using the Offset
function and the code now works.... .
However, whilst the code does work and returns a 'value' in the s/sheet
I have found that I actually need it to return a fomula so that when
the data in the s/sheet changes the 'value' produced by the formula
will adjust. Currently, by producing a value in the code this will not
happen.

When I change the current code from .value = .... to .formula =
"=............" I just get an error.

Any ideas???

Thanks,

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 576
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

Adrian,

Please post your code...

--
sb
"Kobayashi" wrote in message
...
Steve,

Here is my code. I have modified it slightly by using the Offset
function and the code now works.... .
However, whilst the code does work and returns a 'value' in the s/sheet
I have found that I actually need it to return a fomula so that when
the data in the s/sheet changes the 'value' produced by the formula
will adjust. Currently, by producing a value in the code this will not
happen.

When I change the current code from .value = .... to .formula =
"=............" I just get an error.

Any ideas???

Thanks,

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Type mismatch: .Cells(i).Value = "=rc[-1]" / vl

Steve,

Thanks for your help. Code as follows:

Dim avRange As Range
Dim findrange As Range
Dim testRange As Range
Dim FTDRange As Range
Dim FTD As Range
Dim i As Long
Dim LastColumn As Integer
Dim vl As Long
Dim ftd2range As Range
'Application.ScreenUpdating = False


'ActiveSheet.Range.SpecialCells(xlCellTypeLastCell ).Select

Set FTD = Cells.Find("FTD Sum of Spread")
Set findrange = Cells.Find("FTD Sum of
Spread").End(xlToRight).End(xlToRight).End(xlToRig ht) _
.End(xlToRight).End(xlToLeft)
Set FTDRange = Range(findrange, findrange.End(xlUp))
FTDRange.Select
Selection.Copy
FTDRange.Offset(0, 1).PasteSpecial (xlPasteFormats)
Application.CutCopyMode = False
FTDRange(1, 2).Value = "%FTD"
Set FTDRange = Selection

With FTDRange
.Resize(.Rows.Count - 1).Offset(1, 0).Select
Set FTDRange = Selection
End With

For i = 1 To FTDRange.Cells.Rows.Count
FTDRange.Cells(i).Value = (FTDRange.Cells(i).Offset(0,
-1).Value / findrange.Value) * 100
i = i + 1
Next i


Regards,

Adrian



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/

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
"Type mismatch" when I try to fill an Array variable with "+" [email protected] Excel Discussion (Misc queries) 1 April 17th 07 01:28 PM
how do I type "itis" without Excel putting a space "it is"? Max Excel Worksheet Functions 4 March 18th 07 10:22 PM
multiple file uploading - runtime error'13': type mismatch "While Counter <= UBound(FName)" Sinner Excel Discussion (Misc queries) 3 March 1st 07 09:44 AM
Where is the toolbar with the "bold type", "font type", options fwccbcc New Users to Excel 2 May 3rd 06 09:11 PM
Copying data to another worksheet gives "Type Mismatch" error TB[_3_] Excel Programming 6 July 28th 03 12:44 PM


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