Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 8 of 8

Thread: Insert Formula with VBA

  1. #1
    Join Date
    3rd August 2004
    Location
    Canada
    Posts
    93

    Insert Formula with VBA

    Hi,

    In the attached sample workbook, I am trying to insert the formula contained in "C2" down column "C" for each row of data. Is this possible using a Loop? Have I entered the code incorrectly?

    All help is greatly appreciated.

    Excel Video Tutorials / Excel Dashboards Reports


  2. #2
    Join Date
    14th July 2004
    Posts
    10,539

    Re: Insert Formula with VBA

    Dave

    There's no attachment.

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    3rd August 2004
    Location
    Canada
    Posts
    93

    Re: Insert Formula with VBA

    Sorry,


    here it is.

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    3rd August 2004
    Location
    Canada
    Posts
    93

    Re: Insert Formula with VBA

    Norrie:

    I am having difficulty with the attachment. Will try again.

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    3rd August 2004
    Location
    Canada
    Posts
    93

    Re: Insert Formula with VBA

    Hi,

    I believe the file was too large. Here it is.
    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.

    Excel Video Tutorials / Excel Dashboards Reports


  6. #6
    Join Date
    16th June 2005
    Location
    Dublin
    Posts
    4,540

    Re: Insert Formula with VBA

    Hi Dave... maybe, I am missing something here, but Why dont you just drag the formula down (i.e. "fill down") from C2 to C31.... the formula appears to been have been correctly referenced using $, so the references should remain correct all the way down the rows... ? Or do you specifically want to automate this in VBA? (i.e. you might have 1000's of rows....)

    Ger
    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont.

    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25...

    The BEST Lookup function of all time

    Dynamic Named Ranges are your bestest friend

    _______________________________________________

  7. #7
    Join Date
    16th June 2005
    Location
    Dublin
    Posts
    4,540

    Re: Insert Formula with VBA

    If its VBA you want, you could try this...

    This will fill down the formula from C2... to however many rows there are (or to be more specific, to however many rows has data in Column A).

    VB:
    Public Sub fill_Down() 
         
        Dim my_range As Range 
         
        With Worksheets("locman") 
             
            Set my_range = .Range("C2:C" & .Range("A65536").End(xlUp).Row) 
            my_range.Formula = _ 
            "=IF(ISERROR(VLOOKUP(A2,pickcan!A$2:B$90,2,0))," & """OK to Count""" & ", VLOOKUP(A2,pickcan!A$2:B$90,2,0))" 
        End With 
         
    End Sub 
    
    
    HTH
    Ger
    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont.

    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25...

    The BEST Lookup function of all time

    Dynamic Named Ranges are your bestest friend

    _______________________________________________

  8. #8
    Join Date
    3rd August 2004
    Location
    Canada
    Posts
    93

    Re: Insert Formula with VBA

    Ger:

    Yes, automating it with VBA is what I was looking for.

    Thanks a million for your help; works like a charm!

    Excel Video Tutorials / Excel Dashboards Reports


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Possible Answers

  1. Insert Rows With Formula From Row Above
    By Leviathan in forum EXCEL HELP
    Replies: 3
    Last Post: April 17th, 2008, 04:11
  2. Insert Formula Every X Row
    By chenm23 in forum EXCEL HELP
    Replies: 16
    Last Post: March 22nd, 2007, 06:01
  3. Insert Formula With Code
    By Mervyn in forum EXCEL HELP
    Replies: 3
    Last Post: January 7th, 2007, 09:54
  4. Update formula on insert a row
    By farhan_babu in forum EXCEL HELP
    Replies: 2
    Last Post: August 1st, 2005, 18:36
  5. insert formula
    By sekhar in forum EXCEL HELP
    Replies: 2
    Last Post: May 17th, 2003, 05:54

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
porno