change by value

rspalding

Active Member
Joined
Sep 4, 2009
Messages
295
Office Version
  1. 365
Platform
  1. Windows
I need some help.

This would be true for each cell in A1:A10

How do i get this in a VBA code?

if(a1:a10=<>,c1:c10="false","true")

Thanks for the help!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
I think it would help if you were to tell us what your trying to accomplish.

If A1 does not equal C1 then do what?
 
Upvote 0
Try this:


Code:
Sub Does_Not_Equal()
'Modified 9/22/2018 9:41 PM  EDT
Application.ScreenUpdating = False
Dim i As Long

For i = 1 To 10
    If Cells(i, 1).Value <> Cells(i, 3) Then
        Cells(i, 4).Value = "Yes"
    Else
        Cells(i, 4).Value = "No"
    End If
Next
Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
To further explain. C1 is linked to a check box that I want to check automatically when I put data in A1. So once data is entered in AI, I need C1 to say TRUE to make the check box check. The same would then be true for C2 and A2 and on.
 
Upvote 0
Try this:
Will work for A1 to A10
If any value is entered in Column A Rows 1 to 10 column C will have "True" entered.
If Value in Colum A is changed to nothing Column C will no longer have "True"
This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  9/22/2018  11:49:57 PM  EDT
If Not Intersect(Target, Range("A1:A10")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
    If Target.Value <> "" Then
        Target.Offset(, 2).Value = "True"
    Else
        Target.Offset(, 2).Value = ""
    End If
    End If
End Sub
 
Upvote 0
When entering this, I get ambiguous name. Not sure how to change the name correctly.

Private Sub Worksheet_Change(ByVal Target As Range)
'Modified 9/22/2018 11:49:57 PM EDT
If Not Intersect(Target, Range("Q58:Q172")) Is Nothing Then
If Target.Cells.CountLarge > 1 Then Exit Sub
If Target.Value <> "" Then
Target.Offset(, 22).Value = "True"
Else
Target.Offset(, 22).Value = ""
End If
End If
End Sub
 
Upvote 0
That's because you have two change event scripts in the same sheet.
So now you have the one I provided and also another one you made for a different range and maybe more.

So now you have a range of
Q58:Q172
and you have check boxes for all these cells in addition to the original range of A1:A10
Please explain more about what your ultimate goal is.

Having nearly 200 check boxes on your sheets does not seem like a good plan to me.
We have a lot of different ways using Vba to do things. If I knew what your ultimate goal here is I may be able to provide another option.

Show me all code you have in this sheet. We may need to combine some of it. So it will work together properly.

Having True show up in a cell to then have a checkbox activate works but I believe there are better ways
 
Upvote 0
And you never said if the answer I provided in Post 6 ever worked.
It's customary to say if a script provided worked before asking for help on another question.

And in your previous post your wanting to insert values in column Q and putting True in a column 22 columns over from column Q is that what your wanting.

And so we don't keep going on and on. Will there be more to this?

Like column Z and 14 rows over from that?

We cannot just keep adding more and more sheet change event scripts. We have to work them all into one
with different ranges
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,240
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top