+ Reply to Thread
Results 1 to 6 of 6

Pasting formula to multiple sheets and then hard coding the #s

  1. #1
    Registered User
    Join Date
    02-25-2021
    Location
    San Francisco, US
    MS-Off Ver
    2016
    Posts
    10

    Pasting formula to multiple sheets and then hard coding the #s

    Hi there,

    How do write a vba such that I can copy and paste a formula onto the last row of multiple sheets and then hard code it? The formulas are unique in each sheet.

    I have attached an example excel.

    I get new data every month and slip it in as a new tab ie "202102" is the latest Feb data. An index indirect match formula is then used on each sheet to parse the latest data and then I hard code them. I currently do this manually
    Attached Files Attached Files

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Pasting formula to multiple sheets and then hard coding the #s

    Possibly...
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    02-25-2021
    Location
    San Francisco, US
    MS-Off Ver
    2016
    Posts
    10

    Re: Pasting formula to multiple sheets and then hard coding the #s

    Thanks Dangelor. Pardon me for asking but which part of the code does it know to source cell B1 as the formula to copy? And which part of the code hardcodes the numbers?

  4. #4
    Registered User
    Join Date
    02-25-2021
    Location
    San Francisco, US
    MS-Off Ver
    2016
    Posts
    10

    Re: Pasting formula to multiple sheets and then hard coding the #s

    Ah just saw that this uses a used range which doesn't work for me as I need to use the indirect index match formula on cell B1 of every worksheet..

  5. #5
    Registered User
    Join Date
    02-25-2021
    Location
    San Francisco, US
    MS-Off Ver
    2016
    Posts
    10

    Re: Pasting formula to multiple sheets and then hard coding the #s

    I'm using a loop like this so far but sadly the formula pasted is fixed on finding the match with B3 and won't know to use C3

    Sub CopyPasteFormula()

    Dim sht as Worksheet
    Dim My Formula as String

    For Each sht in ThisWorkbook.Worksheets

    My Formula=sht.Range("B1").Formula
    Select Case sht.Name
    Case "202102"
    Case Else
    sht.Range("B" & sht.Rows.Count).End(xlUp).Offset(1).Formula=MyFormula
    sht.Range("C" & sht.Rows.Count).End(xlUp).Offset(1).Formula=MyFormula
    End Select
    Next sht
    End Sub

  6. #6
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Pasting formula to multiple sheets and then hard coding the #s

    which part of the code does it know to source cell B1 as the formula to copy?
    The code doesn't use the formula.
    And which part of the code hardcodes the numbers?
    Please Login or Register  to view this content.

+ 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. Hard-coding formula to reference cell from closed workbook
    By ThomServo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-10-2015, 02:51 PM
  2. Creating new workbook, pasting values, then hard coding last row values.
    By silentcarl in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-13-2015, 03:17 PM
  3. Hard-coding sheets in workbook
    By vio.coman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-29-2014, 03:30 PM
  4. What is better hiding template sheets or hard coding them???
    By JamesGoulding85 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-19-2013, 04:40 AM
  5. pasting formula issue - working with multiple sheets
    By misteremanca in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-17-2008, 04:58 PM
  6. hard coding formulae
    By Dan99 in forum Excel General
    Replies: 2
    Last Post: 05-20-2008, 07:35 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