+ Reply to Thread
Results 1 to 7 of 7

VBA to copy and paste between worksheets based on dynamic value

  1. #1
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    VBA to copy and paste between worksheets based on dynamic value

    Good Morning. I'm looking for some help with VBA. I am still learning this, and I have done copy and pasting with it, but I cant seem to get this to work.

    On the attached workbook I am only concerned with 2 sheets. "Dynamic Calc" and "OTIF"

    On the Dynamic Calc sheet, Cell B2 is going to change monthly. So while it currently shows May-22, next month it will show June-22 when I run my reports.

    What I want to do is click my command button and have the VALUES only from B4:B122 copy and paste to the OTIF sheet in the same range 4:122 based on the month value in row 2.

    So when I push the button now, it should copy Dynamic Calc B4:B122 to and paste the values to OTIF B4:B122 because 'Dynamic Calc B2' is the same as 'OTIF B2'

    However, next month when I change 'Dynamic Calc B2' to "June-22" Then when I press the button the values should paste into "OTIF C4:C122" and so on each month.
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,709

    Re: VBA to copy and paste between worksheets based on dynamic value

    Hi vg05,

    Try below code ...
    Please Login or Register  to view this content.
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: VBA to copy and paste between worksheets based on dynamic value

    Thanks. But when I change the date in B2 on the dynamic calc sheet, and then executing the code again, the data is NOT pasting into the corresponding rows on the OTIF sheet.

    If I change Dynamic Calc B2 to "June-22" then the values should paste into OTIF column C, and If I change Dynamic Calc B2 to July-22 then those values should paste into OTIF column D - they need to paste into the row on OTIF where the row header (row 2) is equal to the date in cell B2 on dynamic calc.

    Currently, it always pasting the data into OTIF column B no matter what date I'm using.

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,709

    Re: VBA to copy and paste between worksheets based on dynamic value

    How are you running the macro ?

  5. #5
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: VBA to copy and paste between worksheets based on dynamic value

    command button

  6. #6
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,709

    Re: VBA to copy and paste between worksheets based on dynamic value

    Check the attached file ...
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-03-2020
    Location
    Wisconsin
    MS-Off Ver
    365
    Posts
    150

    Re: VBA to copy and paste between worksheets based on dynamic value

    Thanks!! Reputation added! I appreciate the help

+ 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. Dynamic copy/paste between Worksheets
    By Gl1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-28-2019, 03:54 PM
  2. Copy a range based on dynamic row numbers and paste into another workbook
    By Grizz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-09-2013, 02:07 PM
  3. Copy/Paste Dynamic Range based on Match Function
    By spyderman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-19-2013, 07:31 PM
  4. paste RNG numbers
    By kaohik78 in forum Excel General
    Replies: 0
    Last Post: 09-26-2012, 10:30 PM
  5. Copy and paste based on found cells using two spreadsheets with dynamic ranges
    By shawnsonline in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-28-2012, 02:49 PM
  6. Copy and paste dynamic range from two worksheets into one
    By wpryan in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-04-2010, 11:35 AM
  7. [SOLVED] Macro Syntax to copy and paste dynamic data based on one column
    By jbsand1001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-17-2005, 10:06 AM

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