Closed Thread
Results 1 to 5 of 5

help with dynamic macro

Hybrid View

  1. #1
    Registered User
    Join Date
    01-08-2019
    Location
    uk
    MS-Off Ver
    2007
    Posts
    4

    help with dynamic macro

    Hi all

    Could someone please help.

    Looking to change the value in the VBA to that of a said cell (A1 for the purpose of this example)

    Basically I have a report generate at look 3 months in advance, I would ideally like to change that 3 month value from a cell and update the macro detail


    (<= Date + 91) within the macro below is what I am trying to allow to be changed i.e. (<= Date + 182) to make the report look further in advance. Ideally trying make it something like (<= Date + A1 report worksheet) in reference to the cell which will dictate the length

    Current VBA for static date used below

    Dim wksSource As Worksheet
    Dim wksDest As Worksheet
    Dim Rng As Range
    Dim Cell As Range
    Dim NextRow As Long

    '//Change the sheet name accordingly
    Set wksSource = Worksheets("trainee all")

    '//Change the sheet name accordingly
    Set wksDest = Worksheets("Reports")

    Set Rng = wksSource.Range("i3:u231")

    For Each Cell In Rng
    If Cell.Value >= Date - 900 And Cell.Value <= Date + 236 And Cell.Interior.ColorIndex = -4142 Then
    NextRow = wksDest.Cells(wksDest.Rows.Count, "c").End(xlUp).Row + 1
    wksSource.Cells(Cell.Row, "a").Resize(, 5).Copy wksDest.Cells(NextRow, "a")
    Cell.Copy
    wksDest.Cells(NextRow, "f").PasteSpecial xlPasteValues
    End

    Hopefully this makes sense,

    Thanks in advance

  2. #2
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,024

    Re: help with dynamic macro

    Hi blueroost
    Welcome to the Forum.
    In future please view the forum rules before posting. Your post does not comply with rule #2.
    Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing.
    So, do the following:
    Edit your post, highlight your code and click the [#] button at the top of the post window.


    EDIT...And rule No 5
    5. Do not open more than ONE thread per issue here. Expect duplicates to be closed. (B)
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  3. #3
    Registered User
    Join Date
    01-08-2019
    Location
    uk
    MS-Off Ver
    2007
    Posts
    4

    Re: help with dynamic macro

    apologies, noob error posting code, as to posting twice, not sure why that happened I never meant to post twice.

    apologies again.

  4. #4
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    15,024

    Re: help with dynamic macro

    No problem...A moderator will delete duplicate post...still need to....do the following:
    Edit your post, highlight your code and click the [#] button at the top of the post window.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    53,051

    Re: help with dynamic macro

    Welcome to the Forum, unfortunately this is a duplicate post and as such will now be closed, you may continue in your other thread.

    Thread Closed.

    https://www.excelforum.com/excel-pro...mic-macro.html
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Help with dynamic macro
    By blueroost in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2019, 02:03 PM
  2. Dynamic Macro
    By Raven911 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-04-2015, 09:35 AM
  3. Dynamic macro
    By a94andwi in forum Excel General
    Replies: 11
    Last Post: 07-18-2014, 07:07 AM
  4. getting macro dynamic
    By flunzy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-04-2013, 07:55 AM
  5. More dynamic macro...
    By belkira in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-28-2009, 03:26 AM
  6. Dynamic Macro
    By Rgaherty in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-22-2008, 07:21 PM
  7. Dynamic Macro's
    By Myrlin1 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-07-2007, 10:00 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