+ Reply to Thread
Results 1 to 7 of 7

vba to copy column data from excel to notepad and separate data with semi colons?

Hybrid View

lilsnoop vba to copy column data from... 06-09-2021, 08:37 PM
6StringJazzer Re: vba to copy column data... 06-09-2021, 09:54 PM
lilsnoop Re: vba to copy column data... 06-09-2021, 10:01 PM
Marc L Try this ! 06-10-2021, 09:13 AM
lilsnoop Re: vba to copy column data... 06-10-2021, 10:21 AM
6StringJazzer Re: vba to copy column data... 06-10-2021, 10:50 AM
lilsnoop Re: vba to copy column data... 06-10-2021, 11:18 AM
  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2021
    Posts
    974

    vba to copy column data from excel to notepad and separate data with semi colons?

    I was hoping for some assistance with a macro that would copy data in a particular column in excel and then copy it to notepad inserting semi colons between the data. Ideally I would like the data in notepad
    to look like 1111111;1111112;11111113; etc instead in a list like (on top of one another) format; though if the first choice isn't possible then the list type would be my second choice.

    I found this code which pulls the data into notepad in a list type format (my 2nd choice) but i would need it to include the semi colons.
    Sub TestNotePad()
         '// The range to copy - written freehand so change as needed
         Range("P2:P100").Copy
         
         '// Start Notepad with focus
         Shell "notepad.exe", vbNormalFocus
         
         '// Send the standard CTRL+V. Pastes to the
         '// active window (Notepad, hopefully)
         SendKeys "^V"
         '// Back to the top of the file
         SendKeys "^{HOME}"
         
    End Sub
    Any help would be appreciated!
    Attached Files Attached Files
    Last edited by lilsnoop; 06-10-2021 at 11:18 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,747

    Re: vba to copy column data from excel to notepad and separate data with semi colons?

    The way I would do this (which may not be what you need) is to export the data to a .txt file, rather than trying to shovel it into Notepad using SendKeys. Then you just open the file in Notepad. I can help with a code revision to do that, if you want.

    If you need to put the data directly into the Notepad app then I'll have to drop out.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2021
    Posts
    974

    Re: vba to copy column data from excel to notepad and separate data with semi colons?

    6StringJazzer-Thank you for your suggestion. I would definitely be interested in trying your method!

  4. #4
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Try this !


    According to your attachment a VBA demonstration as a beginner starter to export the data to a text file :

    PHP Code: 
    Sub Demo1()
        
    Dim F%
            
    FreeFile
            Open ThisWorkbook
    .Path "\Export .txt" For Output As #F
            
    Print #F, Join(Application.Transpose([P2].CurrentRegion.Value2), ";");
            
    Close #F
    End Sub 
    ► Do you like it ? ► So thanks to click on bottom left star icon « Add Reputation » !

  5. #5
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2021
    Posts
    974

    Re: vba to copy column data from excel to notepad and separate data with semi colons?

    Thanks Marc L! I apologize for my ignorance, but once I place this code in a module and run it, what do I do next? Do I need to go to a certain directory, or just do a paste, etc. Really appreciate your help!

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2411
    Posts
    26,747

    Re: vba to copy column data from excel to notepad and separate data with semi colons?

    If you run Marc's code, then it will do basically what I suggested. It will create a file called "Export .txt" and put it in the same folder as your Excel file. The you can open that file with Notepad.

    It uses a very clever method of extracting all the data in one line of code. It will start in P2 and extract the CurrentRegion. However, CurrentRegion will include other columns besides column P if there is data in the adjacent columns, and will cause a runtime error on the call to Join. So it should be tested with your actual data.

  7. #7
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2021
    Posts
    974

    Re: vba to copy column data from excel to notepad and separate data with semi colons?

    Marc and 6StringJazzer, Really appreciate all of the help with this and the explanation!

+ 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] Copy specified data from notepad to excel
    By sarajun_88 in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-12-2017, 11:04 PM
  2. Grouping data in excel and Copy pasting data in Notepad
    By harshit_0078 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-15-2015, 09:49 AM
  3. Copy data from notepad into excel
    By platesigns in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-28-2014, 12:54 PM
  4. =LEN Function for counting semi colons
    By TXNCPO in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2012, 07:06 PM
  5. Excel (2010) Macro to extract string between semi colons
    By merrener in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2012, 04:01 AM
  6. Excel Function - Adding Semi-Colons to Separate Cells
    By roundupriverranch in forum Excel General
    Replies: 3
    Last Post: 03-16-2012, 10:26 PM
  7. 24 hr time calculations without semi colons
    By nje in forum Excel General
    Replies: 4
    Last Post: 08-08-2011, 01:50 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