|
-
May 28th, 2009, 12:23 PM
#1
Thread Starter
New Member
Excel VBA to copy data, open notepad & paste, then copy and paste back to excel
I am admittedly a novice at VBA. I have a need to copy a row of excel data (dates) and copy them, then open up notepad, and paste the data. Then I need to select all from notepad and copy. Then I would like to close notepad, and paste the data back into excel. I am close, but cannot quite figure out how to focus back to excel and close notepad...
Sub CopyAndPasteTimes()
Range("b:b").Copy
Shell "notepad.exe", vbMaximizedFocus
SendKeys "^v"
SendKeys "^a"
SendKeys "^c"
If Application.CutCopyMode = False Then
MsgBox "clipboard empty"
Exit Sub
End If
MsgBox "Copied Times to Notepad and now Pasting back to Excel"
'now activate excel window
Application.Workbooks("working daily excel with macros").Activate
Sheets("Average Start Time data").Select
Columns("B:B").Select
Selection.ClearContents
Range("B1").Activate
SendKeys "^v"
Range("b1").PasteSpecial Paste:=xlPasteAll
MsgBox "Now you can close notepad"
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|