PC Review


Reply
Thread Tools Rate Thread

Cell referencing, formulas, macros

 
 
bpotter
Guest
Posts: n/a
 
      15th Jan 2009
I am trying to insert a formula into a cell using a macro. Is there
anyway I can insert a variable into formula this way?

The formula
=sumproduct(isnumber(search("cyc", u2:u34))*q2:q34)
I would like it to search from u2 to the end of file minus 1 and q2 to
the end of file minus 1.
I am also having problems with relative referencing when I insert the
formula like it is. By taking out r1c1 does this fix this?

Thanks
Bryan
 
Reply With Quote
 
 
 
 
ryguy7272
Guest
Posts: n/a
 
      15th Jan 2009
Turn on the macro recorder and then type the function and then turn off the
macro recorder and then look at the results.

You will see something along the lines of:
..Formula = "yourfunctionhere"

That's pretty much it.

Regards,
Ryan---

--
RyGuy


"bpotter" wrote:

> I am trying to insert a formula into a cell using a macro. Is there
> anyway I can insert a variable into formula this way?
>
> The formula
> =sumproduct(isnumber(search("cyc", u2:u34))*q2:q34)
> I would like it to search from u2 to the end of file minus 1 and q2 to
> the end of file minus 1.
> I am also having problems with relative referencing when I insert the
> formula like it is. By taking out r1c1 does this fix this?
>
> Thanks
> Bryan
>

 
Reply With Quote
 
Rick Rothstein
Guest
Posts: n/a
 
      15th Jan 2009
Give this macro a try...

Sub InsertFormula()
Dim LastRow As Long
With Worksheets("Sheet1")
LastRow = .Cells(.Rows.Count, "U").End(xlUp).Row - 1
.Range("T1").Formula = "=sumproduct(ISNUMBER(SEARCH(U2:U" & _
LastRow & ",""cyc""))*Q2:Q" & LastRow & ")"
End With
End Sub

--
Rick (MVP - Excel)


"bpotter" <(E-Mail Removed)> wrote in message
news:ae9c314b-55a6-4522-8d77-(E-Mail Removed)...
>I am trying to insert a formula into a cell using a macro. Is there
> anyway I can insert a variable into formula this way?
>
> The formula
> =sumproduct(isnumber(search("cyc", u2:u34))*q2:q34)
> I would like it to search from u2 to the end of file minus 1 and q2 to
> the end of file minus 1.
> I am also having problems with relative referencing when I insert the
> formula like it is. By taking out r1c1 does this fix this?
>
> Thanks
> Bryan


 
Reply With Quote
 
bpotter
Guest
Posts: n/a
 
      15th Jan 2009
I can insert the formula into the cell but can I get it to look for
end of the sheet minus 1 row?

 
Reply With Quote
 
bpotter
Guest
Posts: n/a
 
      15th Jan 2009
Works wonderful thankyou

 
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
cell referencing in macros Rusty_Excelman Microsoft Access Macros 1 6th May 2010 03:29 PM
Cell referencing in Macros Rusty_Excelman Microsoft Excel Programming 2 6th May 2010 10:20 AM
Cell referencing in Macros Bern Notice Microsoft Excel Programming 5 28th Feb 2009 11:36 PM
Using data in cell for sheet referencing in formulas MS_user Microsoft Excel Misc 3 31st Oct 2008 10:47 PM
Reletive Referencing of Another Cell's Formulas =?Utf-8?B?RGFtaWFu?= Microsoft Excel Programming 3 18th Jan 2005 06:13 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:55 AM.