+ Reply to Thread
Results 1 to 7 of 7

VBA to copy formula

  1. #1
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    VBA to copy formula

    Formula =IF(I2="Self", 1, IF(I2="Spouce",2, IF(I2="Child",3,IF(I2="Child2",4,IF(I2="Child3",5,IF(I2="Father",7,IF(I2="Mother",8,IF(I2="Father-in-law",9,IF(I2="Mother-in-law",10,"No Relation")))))))))


    Hi I have a data in specified format as per attachment.

    I want vba code to paste above formula in Column C i.e from C2:C till the end of serial number in Column A.


    Or If you can suggest any easiest way
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor abduljaleel.mca's Avatar
    Join Date
    02-13-2013
    Location
    Chennai, India
    MS-Off Ver
    MS 365 Business
    Posts
    326

    Re: VBA to copy formula

    Try this,
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    02-13-2014
    Location
    India
    MS-Off Ver
    Excel 2013
    Posts
    140

    Re: VBA to copy formula

    hi It works, But changes the heading also.
    can you please check it?

  4. #4
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: VBA to copy formula

    Yes it Works, As winmaxservices said it replaces the heading as well.

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to copy formula

    Maybe:

    Change:

    Please Login or Register  to view this content.
    To:

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    11-17-2015
    Location
    India
    MS-Off Ver
    2013
    Posts
    365

    Re: VBA to copy formula

    Correct. Thankyou

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,463

    Re: VBA to copy formula

    Another option

    PHP Code: 
    Sub d()
    Dim Rela()
    Rela = Array("Self""Spouce""Child""Child2""Child3""""Father""Mother""Father-in-law""Mother-in-law")
    With Worksheets("sheet1")
        For 
    2 To .Range("A2").End(xlDown).Row
            
    If IsError(Application.Match(.Cells(i"I"), Rela0)) Then
            Cells
    (i"C").Value "No Relation"
            
    Else:
            
    Cells(i"C").Value Application.Match(.Cells(i"I"), Rela0)
        
    End If
        
    Next i
    End With
    End Sub 
    Quang PT

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Alter existing formula to copy specific cells in row instead of copy entire column
    By painterartist in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-02-2014, 12:42 PM
  2. Replies: 8
    Last Post: 07-08-2013, 06:03 AM
  3. Replies: 3
    Last Post: 01-30-2013, 04:32 PM
  4. make faster copy paste or formula to assist in copy
    By gill389 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-15-2010, 02:07 AM
  5. Copy Multi Formula and then freeze cell refs before second copy
    By Trig79 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 11-23-2009, 07:53 AM
  6. Copy Formula:copy the exact same formula in one column
    By Leprechaun in forum Excel General
    Replies: 1
    Last Post: 12-11-2006, 07:46 PM
  7. [SOLVED] Copy/Paste how to avoid the copy of formula cells w/o calc values
    By Dennis in forum Excel General
    Replies: 10
    Last Post: 03-02-2006, 06:50 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1