LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 25
Default faulty PasteSpecial line??

With much help from Norman a couple of days ago, I have arrived at the
following
piece of code.

Sub moveColsBelow()
'move all data in pre-defined columns, below active cell, down one row
'to create empty cells for a new record.

On Error GoTo err_handler

Range("I" & ActiveCell.Row + 1 & ": K" _
& ActiveSheet.Range("I65536").End(xlUp).Row).Cut

Range("I" & ActiveCell.Row + 2).PasteSpecial xlPasteValues
'This sub freezes on the above line with an error number of 1004
'"PasteSpecial method of Range class failed"
'If the message box in the err_handler is turned off then it works
'tolerably well but requires an {ENTER} to finish.

Exit Sub
err_handler:
MsgBox "Error Number " & Err.Number & "Occurred"
End Sub


This is what I start with:
.. I J K
10 20 20 20
11 71 72 103
12 21 21 21
13 22 22 22
14 23 23 23
15 24 24 24
16 25 25 25
17 26 26 26
18 27 27 27
19 28 28 28
20 29 29 29
21 30 30 30
22
23



after selecting a cell in row 10 and running "moveColsBelow()"
this is what I get and also nearly what I want.

.. I J K
10 20 20 20
11
12 71 72 103
13 21 21 21
14 22 22 22
15 23 23 23
16 24 24 24
17 25 25 25
18 26 26 26
19 27 27 27
20 28 28 28
21 29 29 29
22 30 30 30
23

But I need to press {Enter} in order for the routine to complete.
I have tried many mutations of the SendKeys command and they do
not work. But I do not think that the answer lies with "SendKeys".
I think the PasteSpecial line is faulty.

Also, I would like the routine to finish by making, in this case,
I11 the Active cell - ready to accept new data from the user.

Any help would be greatly appreciated.

Geoff

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
site faulty? stew Excel Discussion (Misc queries) 5 December 29th 08 12:49 AM
Using a PasteSpecial within a Destination:= line drdavidge Excel Worksheet Functions 0 July 13th 06 07:06 PM
Faulty Page Tabs philipallen Excel Discussion (Misc queries) 0 March 24th 06 02:40 PM
Pastespecial and cut Ron[_23_] Excel Programming 4 April 26th 04 02:14 AM
vba pastespecial joao Excel Programming 2 November 14th 03 03:31 PM


All times are GMT +1. The time now is 08:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"