+ Reply to Thread
Results 1 to 15 of 15

Copy data from 1 sheet to another sheet at designated location

  1. #1
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Copy data from 1 sheet to another sheet at designated location

    Hello everyone,

    I am new in this forum

    I need help with the attached file.

    From "Input" sheet, all filled values to be pasted as special in "Output" sheet at predefined cells. Locations are already mentioned in attached sheet. All tables should be generated as per the data available in "Input" sheet.

    "Final Sheet" should be updated based on the data available in "Output" sheet.

    Thanks in advance
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Copy data from 1 sheet to another sheet at designated location

    If I'm not mistaken to understand what you want ....

    Please Login or Register  to view this content.
    Sub output :
    will create "table" as many as rows with data under "BF" in sheet Input.

    Please Login or Register  to view this content.
    Sub final:
    will get each row value of BF and Shade in Sheet Input,
    then put the value into BF and Shade column of FinalSheet as many rows of GSM data of the table in Sheet Output.
    Next, it get the value of GSM and QTY from each table in Sheet Output,
    then put the value into GSM and QTY column of FinalSheet.
    So, there will be a repeating value under BF, Shade and GSM column in FinalSheet ... like the image below for table-01 :

    EXCEL_2022-02-21_17-49-28.png

    FYI, the code doesn't do border formatting either to each "table" in sheet Output or to the data in sheet FinalSheet.

    The code in sub output will create a named range to each "table" GSM section.
    So, the User need to run the output sub first, manually fill the qty to each "table" created by this sub.
    Then later, user can run the final sub to see the result from sheet Output in different way in FinalSheet.
    Last edited by karmapala; 02-21-2022 at 05:58 AM.

  3. #3
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Thanks Karmapala for your help.

    The code is working fine but the range is restricted. In this case, if i add some more values in "Input" sheet I-column, output is not capturing that data and refresh the whole table. This range should be maximum number of cell values in column. And when i remove some values from I-column, it give #N/A error.

    I have used ClearContents to keep format in "Output" sheet.

    With Sheets("Output")
    .Range("A:ZZ").ClearContents
    Last edited by MrDannyShah; 02-23-2022 at 03:21 AM.

  4. #4
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Copy data from 1 sheet to another sheet at designated location

    Quote Originally Posted by MrDannyShah View Post
    Thanks Karmapala for your help.
    if i add some more values in "Input" sheet I-column,
    output is not capturing that data and refresh the whole table.
    Sorry, the code is not creating a real linked table that user can refresh.

    And when i remove some values from I-column, it give #N/A error.
    Sorry, I thought that your column I in sheet Input has a fixed rows.

    I have used ClearContents to keep format in "Output" sheet.
    Except a bold font header, I don't see other formatting in sheet Input ?

    Anyway, please try this output sub version 2:
    Please Login or Register  to view this content.
    Please remember, the code is not creating a linked table on sheet Output based on the data in sheet Input.
    So, each time the data in sheet Input is changed, the user need to run the Ouput sub (again) to see the "tables" in the Output sheet.
    Refreshing those tables in sheet Output (after the data in sheet Input is changed) by clicking Refresh button on the Excel App menu won't work.
    Last edited by karmapala; 02-24-2022 at 11:39 AM.

  5. #5
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Yes!! Thanks Karmapala for your help.

    Code is working fine as per my requirement. Thank you so much. God bless you

  6. #6
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Copy data from 1 sheet to another sheet at designated location

    Glad I can help, MrDannyShah.
    And thanks for the rep.

  7. #7
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Just one more help, in this case we copied Quantity which is a manual field in "Final Sheet". In case, if we have 6 columns manual field and it should be copied in the same way as existing (in "Final Sheet") what changes will be required in code?

  8. #8
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Copy data from 1 sheet to another sheet at designated location

    Sorry, I don't quite understand what did you mean on "manual field" and "6 columns manual field".

    EXCEL_2022-02-28_23-39-47.png

    Did you mean in the Output sheet, the user manually fill each row of GSM of column quantity, bla, bli, blu, ble and blo - like the image above ?

  9. #9
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Yes. You got this right.

  10. #10
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Copy data from 1 sheet to another sheet at designated location

    If that's what you mean, then :
    Output Sub need addition "header" column where the user manually input for each GSM row.

    EXCEL_2022-03-01_16-34-42.png
    In the Output sub, I name the "header" columns : Quantity, BLA, BLI, BLU, BLE, BLO ---> you change it as needed.
    So there are six columns that the user need to input the data manually for each GSM row.

    After run the Output Sub,
    please fill with anything to Quantity, BLA, BLI, BLU, BLE, BLO column of each GSM row on each table in Sheet Output.
    so you can check if after you run the Final Sub, the FinalSheet gives you result as you expected.

    The Ouput Sub and the Final Sub is in Module1 module,
    while the previous two Subs (which only for 1 column manual entry) I put it in OldSub module.

    Please remember that the process is :
    1. Run the Output Sub ---> the result is in sheet Output
    2. Do the manual entry in Sheet Output
    3. Run the Final Sub ---> the result is in sheet FinalSheet

    Before running any code,
    please have a look the beginning condition of sheet Output and sheet FinalSheet.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Its working perfect as desired. Thank you so much karmapala

    Continuously working in this sheet. Sometimes by changing some data and running macro, erased earlier data by mistake.

    Is it possible to have an warning message box that ask some customized msg like "Have you copied data?" and if i click "OK" then macro will run otherwise it will return to the sheet without running macro?

  12. #12
    Valued Forum Contributor
    Join Date
    11-04-2018
    Location
    Denpasar
    MS-Off Ver
    Excel 2010
    Posts
    777

    Re: Copy data from 1 sheet to another sheet at designated location

    Hi MrDannyShah,

    You can add this line of code right after the sub() before any other codes line, something like this :
    Please Login or Register  to view this content.
    So, the first thing the macro do is asking the user by displaying a message box with Yes - No button.
    If the user click the No button, then it exit the sub (do nothing).
    If the user click the Yes button, then it run the rest of the other codes.

  13. #13
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Hello,

    This code is working fine in one sheet. But in another sheet below error found:

    Run-time error '1004': Application-defined or object-defined error.

    Renamed some sheets & cell reference. Code is as below.

    Sub SubteacherSummary()

    UserRespond = MsgBox("Have you copied all data?", vbYesNo)
    If UserRespond = vbNo Then Exit Sub

    With Sheets("Register")
    Set rg = .Range("J5", .Range("K" & Rows.Count).End(xlUp))
    End With

    With Sheets("Input_Subteachers")
    rct = .Range("gsmTbl01").Rows.Count (..........Found error for this................)
    End With

    With Sheets("Sub_Master")
    .Range("B5:E1000").ClearContents
    Set oStart = .Range("B5")
    For i = 1 To rg.Rows.Count
    rgTbl = "gsmTbl" & Format(i, "00")
    oStart.Resize(rct, 2).Value = rg.Rows(i).Value
    oStart.Resize(rct, 2).Offset(0, 2).Value = _
    Sheets("Input_Subteachers").Range(rgTbl).Value
    Set oStart = .Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
    Next
    End With

    End Sub

  14. #14
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Hello,

    I tried the codes in MS 360 and its working completely fine, but when i ran this in MS 2007, I found run time error for below code. Anything to change for MS 2007?

    Code:

    Sub SubteacherSummary()

    With Sheets("Register")
    Set rg = .Range("J5", .Range("K" & Rows.Count).End(xlUp))
    End With

    With Sheets("Input_Subteachers")
    rct = .Range("gsmTbl01").Rows.Count
    End With

    With Sheets("Sub_Master")
    .Range("B5:E1000").ClearContents
    Set oStart = .Range("B5")
    For i = 1 To rg.Rows.Count
    rgTbl = "gsmTbl" & Format(i, "00")
    oStart.Resize(rct, 2).Value = rg.Rows(i).Value
    oStart.Resize(rct, 2).Offset(0, 2).Value = _
    Sheets("Input_Subteachers").Range(rgTbl).Value
    Set oStart = .Range("B" & Rows.Count).End(xlUp).Offset(1, 0)
    Next
    End With

    End Sub

  15. #15
    Registered User
    Join Date
    02-21-2022
    Location
    India
    MS-Off Ver
    365
    Posts
    34

    Re: Copy data from 1 sheet to another sheet at designated location

    Quote Originally Posted by karmapala View Post
    If that's what you mean, then :
    Output Sub need addition "header" column where the user manually input for each GSM row.

    Attachment 770504
    In the Output sub, I name the "header" columns : Quantity, BLA, BLI, BLU, BLE, BLO ---> you change it as needed.
    So there are six columns that the user need to input the data manually for each GSM row.

    After run the Output Sub,
    please fill with anything to Quantity, BLA, BLI, BLU, BLE, BLO column of each GSM row on each table in Sheet Output.
    so you can check if after you run the Final Sub, the FinalSheet gives you result as you expected.

    The Ouput Sub and the Final Sub is in Module1 module,
    while the previous two Subs (which only for 1 column manual entry) I put it in OldSub module.

    Please remember that the process is :
    1. Run the Output Sub ---> the result is in sheet Output
    2. Do the manual entry in Sheet Output
    3. Run the Final Sub ---> the result is in sheet FinalSheet

    Before running any code,
    please have a look the beginning condition of sheet Output and sheet FinalSheet.
    Hello Karmapala,

    Hope you are doing fine.

    When i use this code with the earlier code (Suggested at #2), found run time error. May be due to same "Name Manager" range using in both codes??

+ 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. i want to copy and paste filtered data in different location/sheet
    By ganotra in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-08-2017, 09:22 AM
  2. Macro based on Cell Data-Copy to Specific Location on Different Sheet
    By blackshag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-26-2016, 06:57 AM
  3. Copy row to Sheet 2 only if a change is made to 1 or more of 5 designated cells
    By pnmng49 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-27-2016, 10:45 AM
  4. Copy row to Sheet 2 only if a change is made to 1 or more of 5 designated cells
    By pnmng49 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-22-2016, 09:55 AM
  5. Replies: 3
    Last Post: 05-17-2016, 05:14 PM
  6. [SOLVED] Copy data from specific location in sheet 1 to sheet 2
    By vignesh805 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-07-2013, 01:27 PM
  7. Copy data from one sheet to another at a specified location
    By frank933 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2010, 11:31 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