+ Reply to Thread
Results 1 to 7 of 7

Create Macro for dynamic set of rows in excel

  1. #1
    Registered User
    Join Date
    07-18-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Question Create Macro for dynamic set of rows in excel

    Hi
    Very Good day

    I am tried creating macro in developer option and using Record macro.
    It works for same set of rows. But, when the rows are varying, it is pasting value till the row where i create rows
    For an example, when i record macro, the rows were C6893, in the new sheet rows are C5000, but the macro pasting values till C6893.

    I request you to help me on this.
    This is the macro recorded code on excel
    Sheets("Sheet2").Select
    Columns("C:C").Select
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
    Sheets("Sheet1").Select
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "Today"
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Ageing"
    Range("C2").Select
    ActiveCell.FormulaR1C1 = "=TODAY()"
    Range("D2").Select
    ActiveCell.FormulaR1C1 = "=NETWORKDAYS(RC[-2],RC[-1])"
    Range("D2").Select
    Selection.NumberFormat = "0"
    Range("C2:D2").Select
    Selection.Copy
    Range("B2").Select
    Selection.End(xlDown).Select
    Range("C1274").Select
    Range(Selection, Selection.End(xlUp)).Select
    Range("C2:D1274").Select
    Range("C1274").Activate
    ActiveSheet.Paste
    Sheets("Sheet2").Select
    Range("C1273").Select
    Selection.End(xlUp).Select
    Range("C1:D2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Sheet3").Select
    Range("C14").Select
    Selection.End(xlUp).Select
    ActiveSheet.Paste
    Range("C2:D2").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("B2").Select
    Selection.End(xlDown).Select
    Range("C6892:C6893").Select
    Range("C6893").Activate
    Range(Selection, Selection.End(xlUp)).Select
    Range("C2:D6893").Select
    Range("C6893").Activate
    ActiveSheet.Paste
    Range("C6890").Select
    ActiveWindow.SmallScroll Down:=-24
    Selection.End(xlUp).Select
    End Sub


    Thanks

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Create Macro for dynamic set of rows in excel

    Hi, pavanexcel,

    please wrap your procedure with code-tags like requested in Forum Rule #3.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Create Macro for dynamic set of rows in excel

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: Create Macro for dynamic set of rows in excel

    Hi, pavanexcel,

    maybe you didnīt get the request of Fotis1991 right but you would need to wrap the procedure in the opening post as well as all of the procedure in #4 before you could expect any solution to be given.

    Ciao,
    Holger

  5. #5
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Create Macro for dynamic set of rows in excel

    pavanexcel


    Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore requests by Administrators, Moderators and senior forum members regarding forum rules.

    If you are unclear about the request or instruction then send a private message to them asking for clarification. Do not post a reply in a thread where a moderator has requested an action that has not yet been complied with e.g Title change or Code tags...etc

  6. #6
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: Create Macro for dynamic set of rows in excel

    Pls stop sending private messages and do what we asked for you in post#2 &3.

  7. #7
    Registered User
    Join Date
    07-18-2014
    Location
    India
    MS-Off Ver
    2010
    Posts
    3

    Re: Create Macro for dynamic set of rows in excel

    Hi,

    In sheet 1, there are 66 rows, i have recorded macro. the below code is for the same.

    Please Login or Register  to view this content.
    In sheet, there are 56 rows,but values are pasting till 66. the rows must be dynamic in code

+ 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. Replies: 5
    Last Post: 12-06-2012, 06:52 PM
  2. Replies: 1
    Last Post: 10-05-2011, 03:18 PM
  3. create a dynamic array skipping #N/A and blank rows?
    By William DeLeo in forum Excel General
    Replies: 5
    Last Post: 11-10-2010, 02:55 PM
  4. How to create dynamic rows
    By a94andwi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2010, 03:31 PM
  5. Can i create a Macro to run on dynamic data??
    By james_edstrom in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-08-2009, 09:19 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