Hi - any hints as to why I keep getting an error on the final line?
![]()
Please Login or Register to view this content.
Hi - any hints as to why I keep getting an error on the final line?
![]()
Please Login or Register to view this content.
Last edited by MVscarlet; 04-30-2009 at 07:59 PM.
Hope that's better?
So any ideas?
Last edited by MVscarlet; 04-26-2009 at 11:06 AM.
hi,
To fix your existing code (in the original post) you could just change the last line...
![]()
Please Login or Register to view this content.
Or you could try the below code which I have optimised slightly by removing the un-necessary* use of "select":
*This is the way it is recorded by the macro recorder.
![]()
Please Login or Register to view this content.
hth
Rob
Rob Brockett
Kiwi in the UK
Always learning & the best way to learn is to experience...
Hi
Thanks
I am not 100% sure but it did not work - the debugger still stops it at the ActiveSheet.Paste line....
What is the logic behind theline?![]()
Please Login or Register to view this content.
It really is confusing me because just a paste should be really straightforward and it seemed to work before...even this worked the first time - then it didn't work...any ideas?
Thanks
Ooopps!
Sorry about that, the reason your code doesn't work is that the ".copy" is "undone" (for want of a better word) as soon as another action is done by the code (ie the "Sheets("B").Unprotect"). I would be very surprised if it had even worked once with the way the code is presented - have you change the order of the code since recording it?
To overcome this you need to change the order of your code so that ".copy" is immediately before the ".paste".
I included theto deactivate the clipboard once the range had been pasted into the right place. Without this line it is possible that the range could be re-pasted if [enter] is pressed in the spreadsheet (depending what other lines of code you have). If you were to shrink the VBE window & step through the original code, you could see the dotted "copy lines" around the original range & possibly the comment "select destination & press ENTER or choose paste" at the bottom of the Excel window.![]()
Please Login or Register to view this content.
However, I suggest using my optimised code as this is more efficient (without all the selections & associated screen flickering). The one line tecnique of using "range.copy destination" in my code prevents Excel from showing the previously mentioned comment.
btw, to learn about specific properties & methods in VBA code, you can select the phrase in the VBE window & press [F1] to bring up the Help files.
hth
Rob
Thanksss - that was very useful![]()
I'm pleased I coud help - thanks for the feedback
Rob
I have pasted this the worksheet code but when I hit F5 or play, no macros show up. In fact the only macros that show up are those that I physically record. This doesn't help me b/c I want a date stamp for any time a row of data is modified.
The security is set to low in the file.
Please help b/c my frustration level is out of control!
Thanks
Private Sub Worksheet_Change(ByVal Target As Range)
If Target(1, 1).Row > 1 Then
With Cells(Target(1, 1).Row, "A")
.Value = Date
.EntireColumn.AutoFit
End With
End If
End Sub
hi Crozanski,
Welcome to the Forum
Can you please start a new thread for your question?
(see the Forum Rules esp. #2)
Also, when you start a new thread please wrap your code in "Code Tags" as per Rule #3. If you think it relevant, you can provide a link to this thread in your new thread.
Rob
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks