+ Reply to Thread
Results 1 to 3 of 3

Help Adjusting VBA Code Work On New Rows

  1. #1
    Registered User
    Join Date
    11-09-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    80

    Help Adjusting VBA Code Work On New Rows

    Hey everyone,

    I have attached a sheet to illustrate what I am trying to do, in which I have a macro named 'test'.

    I recorded a the macro to refer from Sheet 1 onto the sheet named Master and was hoping to replace the data in Sheet 1 as and when required and run the macro on the next row of the Master sheet and input the new data. However, whenever I run the macro it does the same again on row 2. It seems from the code that it is because each reference has 2 after it but I don't know how to make it dynamic. Code below; any help greatly appreciated.

    Sub test()
    '
    ' test Macro
    '

    '
    ActiveCell.FormulaR1C1 = "=Sheet1!R1C"
    Range("A2").Select
    Selection.AutoFill Destination:=Range("A2:C2"), Type:=xlFillDefault
    Range("A2:C2").Select
    Range("D2").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(R1C,Sheet1!R4C1:R27C2,2,0)"
    Range("E2").Select
    ActiveCell.FormulaR1C1 = "=VLOOKUP(R1C[-1],Sheet1!R4C1:R27C3,3,0)"
    Range("D2:E2").Select
    Selection.Copy
    Range("F2,H2,J2,L2,N2,P2,R2,T2,V2,X2").Select
    Range("X2").Activate

    Range( _
    "F2,H2,J2,L2,N2,P2,R2,T2,V2,X2,Z2,AB2,AD2,AF2,AH2,AJ2,AL2,AN2,AP2,AR2,AT2,AV2,AX2" _
    ).Select
    Range("AX2").Activate

    ActiveSheet.Paste
    End Sub
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,882

    Re: Help Adjusting VBA Code Work On New Rows

    Hi avendi
    Give this a try ...
    Please Login or Register  to view this content.
    Last edited by YasserKhalil; 07-30-2015 at 03:15 AM.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  3. #3
    Registered User
    Join Date
    11-09-2011
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    80

    Re: Help Adjusting VBA Code Work On New Rows

    Hey Yasser,

    Thanks for that. It kind of did the same thing, but I have decided on a new strategy for my project and will mark the post as such. Thanks very much.

    AV

+ 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. [SOLVED] Help to code not work on Sheet with many rows and columns.
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2015, 10:26 AM
  2. Help to code not work on Sheet with many rows and columns.
    By abjac in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2015, 09:51 AM
  3. Creating a self adjusting work roster
    By ahurtado6421 in forum Excel General
    Replies: 0
    Last Post: 04-03-2015, 08:36 PM
  4. Update Code to work with multiple rows
    By atomichybrid in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-13-2014, 06:07 PM
  5. [SOLVED] code to work for odd rows only
    By kosherboy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 07-04-2014, 10:58 AM
  6. [SOLVED] Code to work on rows 9-220 only
    By Grf in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-12-2012, 05:49 AM
  7. Need help adjusting my code:
    By HouseofRahl in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-12-2005, 06:05 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