+ Reply to Thread
Results 1 to 10 of 10

VBA code to read data and paste in other sheet using a loop.

  1. #1
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Lightbulb VBA code to read data and paste in other sheet using a loop.

    Hello Excel Gurus,

    I am wondering if someone can help me in achieving the below task.

    I need to extract data from few excel templates and consolidate in a different excel workbook.

    I know that it can be done by writing a VBA code to copy respective cells and paste it in other file but the problem is, it is a form template and data is organised in a typical way so wanted to check as how to create a loop to read a range if data is present in that range on the source worksheet.

    In the file attached, I need to copy the data from cells in source sheet and paste in the destination sheet in a particular format. The cells in "FIRST PART" should be copied repeatedly along with all the rows in the "SECOND PART".

    Can somebody help me in writing the VBA code for it?

    Thanks.

    Cross posted at: https://www.mrexcel.com/forum/excel-...ges-sheet.html
    Attached Files Attached Files
    Last edited by jeffreybrown; 02-17-2018 at 07:37 PM.

  2. #2
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA code to read data and paste in other sheet using a loop.

    Did changes in layout of sheet Source, almost none merged cells anymore,
    then this code can do

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Re: VBA code to read data and paste in other sheet using a loop.

    Thanks Leo for your reply.

    The problem I have is, many cells are merged in my template from where I am trying to copy the data and consolidate in another workbook.

    I will take your code and will work on it further to achieve what I want.

    Thanks again Excel Champ.

  4. #4
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA code to read data and paste in other sheet using a loop.

    Is template always same layout as source sheet ?

  5. #5
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Re: VBA code to read data and paste in other sheet using a loop.

    Yes it is.

  6. #6
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Re: VBA code to read data and paste in other sheet using a loop.

    Hi Leo,

    Can you tell me as how can I read more data ranges with this code?

    I have few sheets where more data tables/ranges (in B27:G32 and K27:O32) and I want to copy these ranges also in the destination sheets.

    Thanks for your help.

  7. #7
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA code to read data and paste in other sheet using a loop.

    not mixing 2 different sheets, in the fiile B23 to B32 are merged

    so for file you posted, without changes in layout

    Please Login or Register  to view this content.
    kind regards
    Leo

  8. #8
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Re: VBA code to read data and paste in other sheet using a loop.

    Thanks Leo for your support.

    Can you also help me as how can I copy different ranges from a sheet to designated sheets in other workbook?

    That seems to be very difficult to me to code. I really appreciate if you can help me to learn this.

    Cheers

  9. #9
    Forum Expert
    Join Date
    08-16-2015
    Location
    Antwerpen, Belgium
    MS-Off Ver
    2007-2016
    Posts
    2,380

    Re: VBA code to read data and paste in other sheet using a loop.

    First save the 2 files in same folder

    extra lines of code between End With en End Sub of excisting

    Please Login or Register  to view this content.
    Kind regards
    Leo
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    03-02-2011
    Location
    India
    MS-Off Ver
    Excel 2003/2010
    Posts
    38

    Re: VBA code to read data and paste in other sheet using a loop.

    Thanks Leo.

    You are a STAR..

+ 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. Loop web data into new column on same sheet (Code included)
    By S Thibault in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 02-01-2016, 09:16 PM
  2. Loop web data into new column on same sheet (Code included)
    By S Thibault in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-31-2016, 10:46 PM
  3. [SOLVED] How to write a code within a loop to copy and paste rows on to another Sheet
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-24-2014, 08:40 PM
  4. [SOLVED] Loop through entire sheet, Insert row, copy row data, paste row data, delete row
    By Hyperdude in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-19-2012, 01:46 AM
  5. Code to Read/Copy Data from Closed Wb and Return/Paste in Active Wb
    By AlvaroSiza in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2010, 09:26 PM
  6. Loop to read data from sheet and run all cases
    By khanumair50 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-20-2009, 08:21 AM
  7. Replies: 4
    Last Post: 04-26-2007, 02:13 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