PDA

View Full Version : I need help edit code clean cell and past



etheer
06-13-2013, 03:09 AM
Hi
I have code cleaner cells in sheet account1 and in sheet account2

I need code past cell H4 in cell B4 in sheet account3


Sub clean()
Sheets("ACCOUNT1").Range("K7:K180,L7:L180,AI7:AI180,AJ7:AJ180,AK7:AK180,AL7:AL180,AM7:AM180,AN7:AN180 ,AO7:AO180").ClearContents
Sheets("ACCOUNT2").Range("J7:J184,K7:K184,L7:L184,M7:M184,N7:N184,O7:O184,P7:P184,Q7:Q184,R7:R184,S7: S184,T7:T184").ClearContents
End Sub

p45cal
06-13-2013, 03:19 AM
It's very straightforward.
Add a line like:
Sheets("ACCOUNT3").Range("put your ranges in here separated by commas").clearcontents
just like the other lines. It should be clear how to refer to various blocks of cells, unlike "past cell H4 in cell B4"!

etheer
06-13-2013, 04:00 AM
Thank you p45cal
you can help me and edit code
i need in sheet account3 past cell H4 in cell B4

p45cal
06-13-2013, 04:23 AM
past cell H4 in cell B4I don't know what this means!

etheer
06-13-2013, 04:44 AM
I don't know what this means!

you can download file book1.xlsm and edit code
clean and past cell H4 in cell B4 in sheet account3
i hope you help me

p45cal
06-13-2013, 04:48 AM
you can download file book1.xlsmI have done this. It doesn't tell me any more. The sheet has very little on it.
Oh hold on..
Sheets("Account3").range("H4").copy Sheets("Account3").range("B4")
?

etheer
06-13-2013, 09:14 AM
I have done this. It doesn't tell me any more. The sheet has very little on it.
Oh hold on..
Sheets("Account3").range("H4").copy Sheets("Account3").range("B4")
?
Thank So much p45cal

I edit code


Sheets("ACCOUNT").Range("K7:K180,L7:L180,AI7:AI180,AJ7:AJ180,AK7:AK180,AL7:AL180,AM7:AM180,AN7:AN180 ,AO7:AO180").ClearContents
Sheets("ACCOUNT2").Range("J7:J184,K7:K184,L7:L184,M7:M184,N7:N184,O7:O184,P7:P184,Q7:Q184,R7:R184,S7: S184,T7:T184").ClearContents
Sheets("Account3").Range("H4").Copy Sheets("Account3").Range("B4")

Working code but i need past value

p45cal
06-13-2013, 09:20 AM
Instead:Sheets("Account3").Range("B4").value = Sheets("Account3").Range("H4").Value

etheer
06-13-2013, 12:48 PM
Instead:Sheets("Account3").Range("B4").value = Sheets("Account3").Range("H4").Value


Thank So much p45cal code work 100% but i get one problem clean cell befor paste i need first cell paste and then cleans cells

p45cal
06-13-2013, 05:15 PM
Lines are executed from the top down. Change the order of the lines.

etheer
06-13-2013, 11:02 PM
Lines are executed from the top down. Change the order of the lines.
when change lines



Sub clean()
ActiveSheet.Unprotect Password:="123456"
Sheets("ACCOUNT3").Range("B4").Value = Sheets("ACCOUNT").Range("H4").Value
Sheets("ACCOUNT1").Range("K7:K180,L7:L180,AI7:AI180,AJ7:AJ180,AK7:AK180,AL7:AL180,AM7:AM180,AN7:AN180 ,AO7:AO180").ClearContents
Sheets("ACCOUNT2").Range("J7:J184,K7:K184,L7:L184,M7:M184,N7:N184,O7:O184,P7:P184,Q7:Q184,R7:R184,S7: S184,T7:T184").ClearContents
ActiveSheet.Protect Password:="123456"
End Sub




http://im39.gulfup.com/vOYYX.png

:banghead:

p45cal
06-14-2013, 02:28 AM
Activesheet.unprotect only unprotects the active sheet - the clue is in the first bit.
You have at least 2 other sheets which may need unprotecting. You need to add similar lines.

BUT…
check out the UserInterfaceOnly argument when protecting a sheet. It allows code to change a sheet but not the user at the keyboard.