+ Reply to Thread
Results 1 to 4 of 4

Copy Paste macro with Variable inputs for cell refrencing

  1. #1
    Registered User
    Join Date
    10-26-2021
    Location
    Gwalior
    MS-Off Ver
    Excel 365 Enterprise
    Posts
    4

    Smile Copy Paste macro with Variable inputs for cell refrencing

    Hi All,

    I am new to this Excel Macro world,

    I have made the macro for Copy and paste value substract.
    but Every time I have to Edit the Range to be copied and Range to be pasted.

    I want to make it refer to a particular worksheet so that I do not have to edit Macro every time and make it Variable
    I have tried multiple times but all did not work for referencing.


    Below is the Macro I have written

    Sub Jan_Macro()

    Sheets("Financials").Select
    Range("EV265:FV265").Select -----> ( I want range EV265:FV265 should come from different worksheet called "Update Sheet" and Cell "C2") where I have written EV265:FV265)
    Selection.Copy
    Sheets("Revenue").Select
    Range("EV711:FG711").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlSubtract, _
    SkipBlanks:=False, Transpose:=False

    Sheets("Financials").Select
    Range("EV266:FG266").Select
    Selection.Copy
    Sheets("Financials").Select
    Range("EV189:FG189").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlSubtract, _
    SkipBlanks:=False, Transpose:=False
    End Sub

    I just need way and it will also help me in future projects I also tried searching on google but unable to get perfect solution.

    Thanks in advance
    Atishay

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    36,852

    Re: Copy Paste macro with Variable inputs for cell refrencing

    Try:

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    10-26-2021
    Location
    Gwalior
    MS-Off Ver
    Excel 365 Enterprise
    Posts
    4

    Re: Copy Paste macro with Variable inputs for cell refrencing

    Hi TMS,

    Appreciate your help and quick reply, this was so simple to understand,

    Thank you so much!!

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    36,852

    Re: Copy Paste macro with Variable inputs for cell refrencing

    You're welcome.



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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. in Sheet `inputs' Clear Cell D1 and copy from F1 before running the macro.
    By thilag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-10-2016, 03:44 AM
  2. Macro to copy and paste a variable range
    By richard_a in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-24-2013, 06:26 AM
  3. Macro to copy and paste variable depending on cell content
    By ejh88 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2012, 06:13 PM
  4. refrencing a variable in another sub
    By pavlos in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-16-2010, 04:33 PM
  5. macro code for constant copy but variable paste cell
    By sanpedro_nz in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-04-2009, 03:32 AM
  6. Refrencing a variable cell in a formula
    By C Brehm in forum Excel General
    Replies: 2
    Last Post: 10-10-2005, 11:05 AM

Tags for this Thread

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