logo elektroda
logo elektroda
X
logo elektroda

Open, Copy, and Paste Excel Data from Desktop File: 1.xls, Macro, A:N Columns, First Sheet

zbysiomysio 8097 12
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16274176
    zbysiomysio
    Level 6  
    Hello
    I have a 1.xls file. How to write code to a macro that would open a file from the desktop (indicated by me), copy everything from the first sheet from the A: N columns and paste everything into the Data sheet to the A: N columns in the 1.xls file?
  • ADVERTISEMENT
  • #2 16274717
    adamas_nt
    Moderator of Programming
    zbysiomysio wrote:
    How to write code for a macro
    1. Record the macro that performs the above actions, analyze.
    2. Take a look here , next here
    3. Connect, remove excess code
    4. If something does not work, please describe in the forum.
  • ADVERTISEMENT
  • #3 16274767
    zbysiomysio
    Level 6  
    Thanks for pointing. I recorded and converted the jn macro. I have only one question, i.e. the source file with the macro will be run on different computers. Is it possible for every computer to show a default window to indicate a file from the desktop (so that users do not have to look for the file to be copied, and have a preview of the desktop where the file will be copied from)?
    Code: VBScript
    Log in, to see the code

    Moderated By adamas_nt:

    Please put the code between the Syntax tags

  • ADVERTISEMENT
  • #4 16274821
    adamas_nt
    Moderator of Programming
    FileDialog has many properties. for example:
    . InitialFileName = Environ ("HOMEPATH") & "\ Desktop \"
  • #5 16274875
    zbysiomysio
    Level 6  
    adamas_nt wrote:
    FileDialog has many properties. for example:
    . InitialFileName = Environ ("HOMEPATH") & "\ Desktop \"


    Thanks for the help
    Can anyone else help me what procedure should be given in the above macro so that after copying the columns the file from which the columns were copied is closed and the file to which the columns have been pasted remains open?
  • #6 16276128
    clubs
    Level 38  
    Hello
    I just don't understand what a workbook is
    Windows ("Za + Annex 2 to the order.xls contract bill"). Activate?
    Do you have a macro in one, open the second and copy to the third file?
  • #7 16276194
    zbysiomysio
    Level 6  
    clubs wrote:
    Hello
    I just don't understand what a workbook is
    Windows ("Za + Annex 2 to the order.xls contract bill"). Activate?
    Do you have a macro in one, open the second and copy to the third file?


    Sorry, it is not understandable but I try by trial and error. Below is the partial code of my macro that looks like this:
    Code: VBScript
    Log in, to see the code

    Ultimately, this macro is to copy the A: N columns from the file I specified and paste it into the "IL" worksheet in the gas workbook. The point now is that after copying and pasting these columns the file from which the columns were copied is closed, while the gas application file remains open
  • ADVERTISEMENT
  • #8 16276229
    clubs
    Level 38  
    So in the gaz.xls application you have this macro above?
  • #9 16276234
    zbysiomysio
    Level 6  
    clubs wrote:
    So in the gaz.xls application you have this macro above?

    Yes
  • #10 16276425
    clubs
    Level 38  
    Code: VB.net
    Log in, to see the code
  • #11 16276588
    zbysiomysio
    Level 6  
    Thanks . I haven't mastered it yet, but I understand that if it is to paste into worksheet 3, then after wkb1.Sheets should I put (3)? And what else to add and in which place to clean sheet 3 before pasting? I had it: Sheets ("Sheet3"). Select Cells.Clear
    [quote] wkb2.Sheets (1) .Columns ("A: N"). Copy wkb1.Sheets (1) .Columns ("A: A") [quote]

    Added after 13 [minutes]:

    I already know that you need to improve on Sheets (3), but whether in this code can still be pasted cleaning this sheet3 before pasting
  • #12 16276723
    clubs
    Level 38  
    Code: VB.net
    Log in, to see the code
  • #13 16276800
    zbysiomysio
    Level 6  
    clubs wrote:
    Code: VB.net
    Log in, to see the code


    cool
    Thanks so much for your help. I'm closing the topic.

Topic summary

The discussion revolves around creating a macro in Excel to open a file from the desktop, copy data from columns A:N of the first sheet, and paste it into the "Data" sheet of the 1.xls file. Users suggest recording a macro, utilizing the FileDialog for file selection, and ensuring the macro works across different computers. Key points include setting the initial file path to the desktop, closing the source workbook after copying, and clearing the destination sheet before pasting. The final macro code provided demonstrates these functionalities effectively.
Summary generated by the language model.
ADVERTISEMENT