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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paste Special without selecting

Status
Not open for further replies.

duncansancho

Technical User
Oct 9, 2003
45
0
0
GB
Hi all,
I am trying to clean up some macros by removing all the "select"'s as explained by Skip. I have succeeded in speeding up a lot of processes but am having trouble with copying the result of formulas as a value. I can use the following code to copy a variable length column, but how can I do it when it needs Paste Special?

Range(Sheets("Input").Range("A1"), Sheets("Input").Range("A1").End(xlDown)).Copy Sheets("Output").Range("D7")

Duncan
 
You can simply find the last row of your data as follows:
lrow = Sheets("Input").Range("A1").End(xlDown)

then you could write something like this

for i = 1 to lrow
Sheets("Output").cells(7+i,4) = Sheets("Input").cells(i,1)
next i

So, with this way, you just copy the values and nothin else! Alternative you can record a macro and instead of paste choose paste special - only values. Then use the recorded macro for your need. I thing that will help.
 
You still don't need to select. Use soemthing like this:

Range(Sheets("Input").Range("A1"), Sheets("Input").Range("A1").End(xlDown)).Copy

Sheets("Output").Range("D7").PasteSpecial Paste:=xlValues

Just have 2 statements to do this instead.


Glenn.
 
Thanks to you both - sorry for the delay in replying, I was called away!
Duncan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top