Correcting VBA code in Excel
Solved/Closed
Issa
-
Feb 6, 2012 at 08:32 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Mar 15, 2012 at 10:25 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - Mar 15, 2012 at 10:25 AM
Related:
- Correcting VBA code in Excel
- Battery reset code - Guide
- Number to words in excel formula without vba - Guide
- Samsung volume increase code - Guide
- How to get whatsapp verification code online - Guide
- Vba case like - Guide
1 response
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Feb 6, 2012 at 09:42 AM
Feb 6, 2012 at 09:42 AM
Hi Issa,
Good to see you again. Did you know that when you become a member it is easier to keep track of your messages? Just a suggestion.
For your current query I assumed you want to clear the contents of column T and U of the target row.
Best regards,
Trowa
Good to see you again. Did you know that when you become a member it is easier to keep track of your messages? Just a suggestion.
For your current query I assumed you want to clear the contents of column T and U of the target row.
Private Sub Worksheet_Change(ByVal Target As Range) Dim cRow As Integer If Intersect(Target, Range("R11:R20")) Is Nothing Then Exit Sub If Target.Value = "F" Then ActiveSheet.Unprotect cRow = Target.Row With Range(Cells(cRow, "T"), Cells(cRow, "U")) .ClearContents .Locked = True End With ActiveSheet.Protect End If If Target.Value = "T" Or Target.Value = "" Then ActiveSheet.Unprotect cRow = Target.Row Range(Cells(cRow, "T"), Cells(cRow, "U")).Locked = False ActiveSheet.Protect End If End Sub
Best regards,
Trowa
Feb 6, 2012 at 02:17 PM
Thank a lot to all your assistance.
Yes I would like to be one member of the greatest experts in programming, but how can I?
The code is working in normal situation, but my problem didn't solved yet.
The problem is that the value of Column (R) depending on the value of column (T)and (U), The function in column (R) is "IF formula" depending on column (T)and (U).
For example:
Column (R1): =if(or(T1>5,U1="M"),"F","T")
Now I need if the user entered (10) in (T1 ) and (M) in (U1) to run the code automaticly.
But I noticed that it will work only after going to (R1) and pressing F2 then Enter-Key.
Hope it's more clear now.
Thank you again in advance to all your support and help.
Best regards,
Issa
Feb 7, 2012 at 09:50 AM
So if T1=6, R1 will be "F", this will clear T1 of it's contents.
T1 is now empty, thus R1 will be "T".
As you can see, R1 can never be "F"; if it does, the code will remove the requirements for it to be "F".
Maybe I misunderstood and you want to clear the contents of the targets row except the value's of R, T and U?
Please clearify.
And you don't have to be an expert (or helping others for that matter) to join Kioskea. It's just more convenient to be a member when you use this site on frequent occasion.
Kind regards,
Trowa
Feb 8, 2012 at 08:56 AM
Yes you are absolutely right, I mean (if(and)) not (if(or)), sorry for that.
By the way, I became now a member in Kioskea.net now :) (my username is "issahamameh03")
Thank you again for all your interest and support.
BR,
Feb 9, 2012 at 10:04 AM
I'm still gonna call you Issa, if you don't mind.
But your query remains unsolved right? The formula containing AND instead of OR doesn't change the problem.
Kind regards,
Trowa
Feb 10, 2012 at 12:37 AM
Of course I don't mind to call, if needed my mobile Personal data deleted by aquarelle (Moderator)
I have an idea in order my problem to be solved that if you can change the code to be from (Private Sub Worksheet_Change) to (Private Sub CommandButton1_Click()), in this case just change the code to fit this option then I'm sure it will work. I would be very grateful for that.
Thank you and best regards,