+ Reply to Thread
Results 1 to 6 of 6

Copying and Pasting Data from Excel to Notepad

  1. #1
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    Copying and Pasting Data from Excel to Notepad

    Hello,
    Having issues with the code of being able to copy and paste from Excel to Notepad. The issue specifically is how inconsistent the results are. Results I've seen are, data gets pasted, not pasted. Not sure what I am doing wrong and any help would be appreciated.

    Copy of code I've been trying:

    Sub CopyDataExcelNotepad()
    Worksheets("Sheet2").Activate
    Range("A:A").Copy
    myApp = Shell("Notepad.exe", vbNormalFocus)
    SendKeys "^v"
    CutCopyMode = False
    End Sub

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: Copying and Pasting Data from Excel to Notepad

    Hi JSH,

    I have no idea what else is happening in your code, so this is just a guess.

    Put a "DoEvents" just before SendKeys (do it after also) and see what happens.

    https://msdn.microsoft.com/en-us/vba...vents-function
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

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

    Re: Copying and Pasting Data from Excel to Notepad


    Hi !

    The easy way is to export worksheet to a text file then open this text file via NotePad …

  4. #4
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Copying and Pasting Data from Excel to Notepad

    Quote Originally Posted by MarvinP View Post
    Hi JSH,

    I have no idea what else is happening in your code, so this is just a guess.

    Put a "DoEvents" just before SendKeys (do it after also) and see what happens.
    Hi MarvinP

    I didn't have to change the code. In confusion I overlooked where the scroll bar was after the macro completed because it copies all of column A, blanks included.
    Pretty novice miss on my end...

    To fine tune it, since it is copying the entire column is there a way for it to stop at the last cell with data in it? I looked up LastRow code for VBA but I saw examples needing a cell reference which in this case I can't apply a cell reference due to the amount of the data can vary each time I go to run the macro.
    Last edited by JSH2017; 04-26-2018 at 09:21 AM.

  5. #5
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Copying and Pasting Data from Excel to Notepad

    Quote Originally Posted by Marc L View Post

    Hi !

    The easy way is to export worksheet to a text file then open this text file via NotePad …
    Hi Marc L,
    Thanks for the suggestion. What I am working on I want to be able to run a macro and have the majority of the data processing automated with one run of a macro.
    Plus this forces me to learn more about VBA.

  6. #6
    Registered User
    Join Date
    05-21-2017
    Location
    USA
    MS-Off Ver
    Office 365
    Posts
    14

    Re: Copying and Pasting Data from Excel to Notepad

    Quote Originally Posted by JSH2017 View Post
    Hi MarvinP

    I didn't have to change the code. In confusion I overlooked where the scroll bar was after the macro completed because it copies all of column A, blanks included.
    Pretty novice miss on my end...

    To fine tune it, since it is copying the entire column is there a way for it to stop at the last cell with data in it? I looked up LastRow code for VBA but I saw examples needing a cell reference which in this case I can't apply a cell reference due to the amount of the data can vary each time I go to run the macro.
    Disregard this request.

    Adding the below at the end fine tuned it well enough.
    SendKeys "^{Home}"

+ 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. 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
  2. Opening Notepad a saved notepad file and copying the data on it
    By swade730 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-20-2014, 06:18 PM
  3. Pasting Excel data to Notepad
    By butcher11 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-09-2013, 04:28 PM
  4. Copying more than one range of data from excel into more than one notepad file
    By brianQ in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 01:25 PM
  5. Pasting content from Excel to Notepad
    By kandanuru in forum Excel General
    Replies: 1
    Last Post: 10-31-2012, 02:35 AM
  6. Copying the data from two notepad files to an Excel workbook
    By raghunaik in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-10-2009, 12:17 AM
  7. copying data from excel into notepad
    By walid66 in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 01-19-2007, 03:58 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