Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using windows clipboard for copying and pasting.

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
HI


In VBA for Excel is it possible to mark a range, copy the values of the range to the clipboard and paste the contents again in another sheet of the same workbook. please help. I am thinking of alternatively storing the values of the range in an array and then copying the contents of the array back in another cell. thanx.


toparag.
 
There's no need to use the clipboard. Excel already knows how to copy and paste. The VBA code below copies from the currently active sheet range A1-A6 to Sheet2 Range A1-A6. I recorded this macro in excel after reading your post. The code does exactly what i wanted it to without me writing a single line of code. The moral of the story here is that if you know how to do something with your mouse and keyboard in excel, then you know how to write the vba code for it. Just choose record macro off the tools menu and go through the process using your mouse and keyboard. In many cases you will need to tweak the macro after it's recorded, but much of the work is still done for you.

Code:
    Range("A1:A6").Select
    Selection.Copy
    Sheets("Sheet2").Select
    ActiveSheet.Paste
    Range("B7").Select
Ruairi

Could your manufacturing facility benefit from real time process monitoring? Would you like your employees to be able to see up to the minute goal and actual production?
For innovative, low cost solutions check out my website.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top