+ Reply to Thread
Results 1 to 3 of 3

VBA: Copying formula from one worksheet to another

  1. #1
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Post VBA: Copying formula from one worksheet to another

    Hello! I really need answers from the experts here....

    I've been trying to solve this problem but nothing worked!

    What i basically want is to have this formula to be copied into a cell in "Consolidated Report" where the SheetName varies.

    =SheetName!$B$35

    What i'm trying to do is create new worksheet & rename the sheet name base from inputbox value. Then insert row in the "Consolidated Report" worksheet where it shows all sheet names in "A" column and total figures from each worksheet in "B" column. I managed to create worksheet, rename the sheet name, and insert a row in "Consolidated Report" with the new sheet name in "A" column.

    But what I can't do is copy the formula in "B" column that shows total figures from the referenced sheet. So that when user adds details, the total for that particular sheet AND in "Consolidated Report" sheet will also be updated.

    I badly need enlightment on this. Thanks a lot!
    -hydz1213

    Please Login or Register  to view this content.

  2. #2
    Forum Contributor codeslizer's Avatar
    Join Date
    05-28-2013
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2003 - 2010
    Posts
    245

    Re: VBA: Copying formula from one worksheet to another

    Well, I can give you some light.. You can use INDIRECT function in column B to create the range from text available in A column.
    Please Login or Register  to view this content.
    Tip: To further flexibility, you can define "!B2" as "!B" & ROW() or similar to get the right cell for your needs

    Now, we have the function, but I want it to get populated everytime, I feed sheet names in column A. So, write the following code in the Worksheet_Change() event to capture the changes in column A and put the formula to column B.

    Please Login or Register  to view this content.
    This should do the trick. Let me know for if this isn't what you need. It would be great if you could upload a sample work file removing all your sensitive data if any. Am attaching a sample implementation of what I said.
    Attached Files Attached Files
    Last edited by codeslizer; 08-14-2013 at 07:06 AM.
    cOdEsLiZeR - Back after a long break.. Let's sLiZe some more cOdEs!!

  3. #3
    Registered User
    Join Date
    01-15-2013
    Location
    Dubai, UAE
    MS-Off Ver
    Excel 2010
    Posts
    57

    Re: VBA: Copying formula from one worksheet to another

    Thank you so much codeslizer for the help! It does allow me to reference a range of specific worksheet. Good job!

+ 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. [SOLVED] Copying formula from one worksheet to another
    By annieflanz in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-30-2013, 09:23 PM
  2. Copying A Formula between tabs in a worksheet
    By Gooford in forum Excel General
    Replies: 8
    Last Post: 10-09-2009, 07:04 AM
  3. Copying formula to new worksheet: how to stop formula linking to original source?
    By test-card girl in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 08-30-2007, 07:32 AM
  4. Copying a Formula which contains a link to another worksheet
    By Shirley Munro in forum Excel General
    Replies: 4
    Last Post: 02-03-2006, 05:06 AM
  5. [SOLVED] Copying result of formula into another worksheet???
    By Amanda in forum Excel General
    Replies: 3
    Last Post: 04-15-2005, 05:06 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