PC Review


Reply
Thread Tools Rate Thread

Assigning a formula to a range

 
 
Vagabound_s
Guest
Posts: n/a
 
      29th Oct 2008
I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
to a range "B11:K158".

I know that we can do this using loop.

However, Can I do that in VBA without using loop, with appriopriate and
relative cell refrences . for example A11 references B11 cells and D11 cells.
 
Reply With Quote
 
 
 
 
Barb Reinhardt
Guest
Posts: n/a
 
      29th Oct 2008
Dim myRange As Range
Set myRange = Range("B11:K158")
myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"

--
HTH,
Barb Reinhardt

If this post was helpful to you, please click YES below.



"Vagabound_s" wrote:

> I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
> to a range "B11:K158".
>
> I know that we can do this using loop.
>
> However, Can I do that in VBA without using loop, with appriopriate and
> relative cell refrences . for example A11 references B11 cells and D11 cells.

 
Reply With Quote
 
Vagabound_s
Guest
Posts: n/a
 
      31st Oct 2008
Thank you! it really helped and saved lot of efforts writing loops.

"Barb Reinhardt" wrote:

> Dim myRange As Range
> Set myRange = Range("B11:K158")
> myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
>
> --
> HTH,
> Barb Reinhardt
>
> If this post was helpful to you, please click YES below.
>
>
>
> "Vagabound_s" wrote:
>
> > I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
> > to a range "B11:K158".
> >
> > I know that we can do this using loop.
> >
> > However, Can I do that in VBA without using loop, with appriopriate and
> > relative cell refrences . for example A11 references B11 cells and D11 cells.

 
Reply With Quote
 
Vagabound_s
Guest
Posts: n/a
 
      11th Nov 2008
Just one more thing on this:

What if my reference cells happen to be in another sheet. I tried using
below code, but it did not work. Is there any other syntax?

myRange.FormulaR1C1 =
"=IF(Sheet1!RC[-1]=""Void"",""Void"",ROUND(Sheet1!RC[2]*80%,1))"



"Vagabound_s" wrote:

> Thank you! it really helped and saved lot of efforts writing loops.
>
> "Barb Reinhardt" wrote:
>
> > Dim myRange As Range
> > Set myRange = Range("B11:K158")
> > myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
> >
> > --
> > HTH,
> > Barb Reinhardt
> >
> > If this post was helpful to you, please click YES below.
> >
> >
> >
> > "Vagabound_s" wrote:
> >
> > > I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
> > > to a range "B11:K158".
> > >
> > > I know that we can do this using loop.
> > >
> > > However, Can I do that in VBA without using loop, with appriopriate and
> > > relative cell refrences . for example A11 references B11 cells and D11 cells.

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      11th Nov 2008
What happened when you tried it?

What sheet was myRange on?
What address was myRange?



Vagabound_s wrote:
>
> Just one more thing on this:
>
> What if my reference cells happen to be in another sheet. I tried using
> below code, but it did not work. Is there any other syntax?
>
> myRange.FormulaR1C1 =
> "=IF(Sheet1!RC[-1]=""Void"",""Void"",ROUND(Sheet1!RC[2]*80%,1))"
>
> "Vagabound_s" wrote:
>
> > Thank you! it really helped and saved lot of efforts writing loops.
> >
> > "Barb Reinhardt" wrote:
> >
> > > Dim myRange As Range
> > > Set myRange = Range("B11:K158")
> > > myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
> > >
> > > --
> > > HTH,
> > > Barb Reinhardt
> > >
> > > If this post was helpful to you, please click YES below.
> > >
> > >
> > >
> > > "Vagabound_s" wrote:
> > >
> > > > I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
> > > > to a range "B11:K158".
> > > >
> > > > I know that we can do this using loop.
> > > >
> > > > However, Can I do that in VBA without using loop, with appriopriate and
> > > > relative cell refrences . for example A11 references B11 cells and D11 cells.


--

Dave Peterson
 
Reply With Quote
 
Vagabound_s
Guest
Posts: n/a
 
      12th Nov 2008
Hi Dave, thanks for your prompt response, here is full code:

Dim myRange As Range
Set myRange = Sheet3.Range("B11:B159")
myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
Set myRange = Sheet3.Range("C11:C159")
myRange.FormulaR1C1 = "=IF(RC[-2]=""Void"",""Void"",ROUND(RC[1]*20%,1))"
Set myRange = Sheet3.Range("D11159")
myRange.FormulaR1C1
"=IF(Jobs!RC[-3]=""Void"",""Void"",IF(ISNUMBER(Jobs!RC[4]),Jobs!RC[4],0))"

when I run this it gives and error "Compiler error: Invalid use of property"

"Dave Peterson" wrote:

> What happened when you tried it?
>
> What sheet was myRange on?
> What address was myRange?
>
>
>
> Vagabound_s wrote:
> >
> > Just one more thing on this:
> >
> > What if my reference cells happen to be in another sheet. I tried using
> > below code, but it did not work. Is there any other syntax?
> >
> > myRange.FormulaR1C1 =
> > "=IF(Sheet1!RC[-1]=""Void"",""Void"",ROUND(Sheet1!RC[2]*80%,1))"
> >
> > "Vagabound_s" wrote:
> >
> > > Thank you! it really helped and saved lot of efforts writing loops.
> > >
> > > "Barb Reinhardt" wrote:
> > >
> > > > Dim myRange As Range
> > > > Set myRange = Range("B11:K158")
> > > > myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
> > > >
> > > > --
> > > > HTH,
> > > > Barb Reinhardt
> > > >
> > > > If this post was helpful to you, please click YES below.
> > > >
> > > >
> > > >
> > > > "Vagabound_s" wrote:
> > > >
> > > > > I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
> > > > > to a range "B11:K158".
> > > > >
> > > > > I know that we can do this using loop.
> > > > >
> > > > > However, Can I do that in VBA without using loop, with appriopriate and
> > > > > relative cell refrences . for example A11 references B11 cells and D11 cells.

>
> --
>
> Dave Peterson
>

 
Reply With Quote
 
Vagabound_s
Guest
Posts: n/a
 
      12th Nov 2008
Dave,

Thanks raising doubt, I revisited the code and found that I missed the "="
sign in my origional code.

"Vagabound_s" wrote:

> Hi Dave, thanks for your prompt response, here is full code:
>
> Dim myRange As Range
> Set myRange = Sheet3.Range("B11:B159")
> myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
> Set myRange = Sheet3.Range("C11:C159")
> myRange.FormulaR1C1 = "=IF(RC[-2]=""Void"",""Void"",ROUND(RC[1]*20%,1))"
> Set myRange = Sheet3.Range("D11159")
> myRange.FormulaR1C1
> "=IF(Jobs!RC[-3]=""Void"",""Void"",IF(ISNUMBER(Jobs!RC[4]),Jobs!RC[4],0))"
>
> when I run this it gives and error "Compiler error: Invalid use of property"
>
> "Dave Peterson" wrote:
>
> > What happened when you tried it?
> >
> > What sheet was myRange on?
> > What address was myRange?
> >
> >
> >
> > Vagabound_s wrote:
> > >
> > > Just one more thing on this:
> > >
> > > What if my reference cells happen to be in another sheet. I tried using
> > > below code, but it did not work. Is there any other syntax?
> > >
> > > myRange.FormulaR1C1 =
> > > "=IF(Sheet1!RC[-1]=""Void"",""Void"",ROUND(Sheet1!RC[2]*80%,1))"
> > >
> > > "Vagabound_s" wrote:
> > >
> > > > Thank you! it really helped and saved lot of efforts writing loops.
> > > >
> > > > "Barb Reinhardt" wrote:
> > > >
> > > > > Dim myRange As Range
> > > > > Set myRange = Range("B11:K158")
> > > > > myRange.FormulaR1C1 = "=IF(RC[-1]=""Void"",""Void"",ROUND(RC[2]*80%,1))"
> > > > >
> > > > > --
> > > > > HTH,
> > > > > Barb Reinhardt
> > > > >
> > > > > If this post was helpful to you, please click YES below.
> > > > >
> > > > >
> > > > >
> > > > > "Vagabound_s" wrote:
> > > > >
> > > > > > I want to assign a formula say, "=IF(A11="Void","Void",ROUND(D11*80%,1))"
> > > > > > to a range "B11:K158".
> > > > > >
> > > > > > I know that we can do this using loop.
> > > > > >
> > > > > > However, Can I do that in VBA without using loop, with appriopriate and
> > > > > > relative cell refrences . for example A11 references B11 cells and D11 cells.

> >
> > --
> >
> > Dave Peterson
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning AutoFiltered Range to Range Object Simon Microsoft Excel Programming 5 11th Mar 2009 01:04 AM
Assigning a hotkey to run only from a given range Andyjim Microsoft Excel Programming 3 27th Dec 2007 01:41 AM
Assigning Formula to a Range JMay Microsoft Excel Programming 5 23rd Feb 2007 10:12 PM
Assigning an IP range for ICS =?Utf-8?B?SGF3a2V5ZQ==?= Windows XP Networking 2 16th Dec 2004 06:21 PM
Assigning a Range to Alex A Microsoft Excel Programming 2 30th Jan 2004 12:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:00 PM.