+ Reply to Thread
Results 1 to 15 of 15

Value copying

  1. #1
    Registered User
    Join Date
    09-22-2012
    Location
    colombo,srilanka
    MS-Off Ver
    Excel 2007
    Posts
    11

    Value copying

    i have a excel file and i want to copy some values in Column A to Column D. I want a macro to do this. need to take account of following when writing the macro.
    1. All values in column A not needed to be copied to column D. values one after another needed to be copied.
    2. last row which contains a value that need to be copied to column D can be change time to time.

    I recorded below macro but i think this is not the best one to carry out above requirement. I have attached the excel sheet for your reference.

    Please Login or Register  to view this content.
    Thnks.


    Moderator Edit:

    Welcome to the forum, mfmalthaf.

    Please notice that code tags have been added to your post. The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.
    Attached Files Attached Files
    Last edited by Cutter; 09-22-2012 at 12:24 PM. Reason: Added code tags

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Value copying

    As a matter if interest, why do you need a Macro for this?
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Value copying

    a simplified version of your code.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    09-22-2012
    Location
    colombo,srilanka
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value copying

    What i have uploaded here is a just a example of the actual document. Actual document could have about 100-150 lines and i get 300 of such documents daily. so its very convenient if i have a macro to do this

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Value copying

    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    09-22-2012
    Location
    colombo,srilanka
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value copying

    This doesn't work.
    Your first macro worked but even it worked only for one cell

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

    Re: Value copying

    Hi, mfmalthaf,

    change the code line
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    But I donīt see a need for a loop here.
    Please Login or Register  to view this content.
    should work without the loop.

    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

  8. #8
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Value copying

    Please Login or Register  to view this content.
    Kind regards, Harry.

  9. #9
    Registered User
    Join Date
    09-22-2012
    Location
    colombo,srilanka
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value copying

    Ciao this works...but if i extended the values of column A further down then macro doesn't work for the extended values (Please see point 2 in my post)

  10. #10
    Registered User
    Join Date
    09-22-2012
    Location
    colombo,srilanka
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: Value copying

    HSV this works really well...Thank you...

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Value copying

    Should the Code not be:

    Please Login or Register  to view this content.

  12. #12
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Value copying

    Sorry for missing D3 from my line. Yes this line works if you extended your data to last row
    Please Login or Register  to view this content.
    This shows you from row 3 up your last row data on column "C"

  13. #13
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Value copying

    No Winon,
    Step 2 means:
    4,6,8 etc.
    Cells(i,1) = cells(4,1)
    next
    cells(i,1) = cells(6,1)

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Value copying

    @ HSV,

    Hi Harry,

    Very sorry about that, I completely missed this in the Thread:

    All values in column A not needed to be copied to column D. values one after another needed to be copied.

  15. #15
    Valued Forum Contributor
    Join Date
    02-12-2011
    Location
    The Netherlands
    MS-Off Ver
    365
    Posts
    818

    Re: Value copying

    To @Winon,

    That can happen.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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