LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default imitating cut and paste


Hi Ben,
I'm only learning too so if there is someone with a better suggestion,
*please speak up*.

Yes, you are right, excel is trying to adjust the formulae but "A
display of #REF! means that your formula refers (directly or
indirectly) to a cell that no longer exists, due to a change in the
worksheet/workbook/other precedents."
In your case, the cutting & pasting you are doing changes the worksheet
structure & therefore your formulae *will not work*/be accurate - as you
have shown with your example. I'd recommend copying the "if" formula
down from the top row of all your status columns so you know it is
referencing the correct cells. I suspect that any cutting you have done
in the past will have thrown some of the formulae out of sync so that
even some that work are not referring to the correct row. This can be
easily checked by selecting a cell in column E & pressing F2 - the
cells that are being referenced are usually highlighted when this is
done.

I still question the need for cutting & moving the data around b/c I
assume it is being moved due to a change in the "status" column. If
this is the case, have you considered using data - sort, & rearranging
the rows based on column E?
However, I've had a play & modified the below for you. It isn't the
"ideal" that you requested but may be better (?) as it includes both "a
copy + stores the range and then pastes & delete/clears the stored range
from earlier". It appears to work but I haven't been thorough with error
testing/trapping.
NB, this macro deletes the complete rows which your copy range was on
to prevent the "#ref!" problem. However, if you have more information
in column F & further right, remove the 2 lines ending with '* &
replace with line1 "Range(MyAddr).Delete Shift:=xlUp" and line2
"range("e2").copy Range("e2", Selection.End(xlDown))".


Sub CopyPasteAndDeleteOriginalRange()
'sourced (& modified) from
http://www.experts-exchange.com/Appl..._20629300.html
Dim prompt, sDlgTitle As String
prompt = "Select a range"
sDlgTitle = "Get User Range"
On Error Resume Next
Set URng = Application.InputBox("Select range", sDlgTitle,
ActiveCell.Address, Type:=8)
MyAddr = URng.Address
Set PasteRng = Application.InputBox("Select range", sDlgTitle,
ActiveCell.Address, Type:=8)
MyPasteAddr = PasteRng.Address
If URng Is Nothing Then Exit Sub
'COPY, PASTE, & DELETE CODE HERE USING THE RANGE DEFINED BY YOUR
SELECTION.
Range(MyAddr).Copy Range(MyPasteAddr)
Range(MyAddr).EntireRow.Select '*
Selection.Delete Shift:=xlUp '*
MsgBox "Done"
End Sub

Hth
Rob Brockett
NZ
Still learning & the best way to learn is to experience...


--
broro183
------------------------------------------------------------------------
broro183's Profile: http://www.excelforum.com/member.php...o&userid=30068
View this thread: http://www.excelforum.com/showthread...hreadid=499117

 
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
Paste and Paste Special No Longer Working - Excel 2003 SheriJ Excel Discussion (Misc queries) 2 January 15th 09 09:23 PM
Excel cut/Paste Problem: Year changes after data is copy and paste Asif Excel Discussion (Misc queries) 2 December 9th 05 05:16 PM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
How do I capture user paste action and convert to Paste Special DonC Excel Programming 0 November 19th 04 01:43 PM
Imitating Pivot table's context awareness R Avery Excel Programming 3 September 17th 04 05:19 PM


All times are GMT +1. The time now is 03:37 PM.

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

About Us

"It's about Microsoft Excel"