alisoncleverly
New Member
- Joined
- Feb 20, 2020
- Messages
- 28
- Office Version
- 2013
- Platform
- Windows
Hi everyone,
I tried the following code to do: If any Sales cells have "Title Transfer" then the 51st column would have an "x".
I have 8 columns named "Sales" in total. The 5st column is named "Title Transfer".
However, I realised there was more to my original purpose and the above codes weren't flexible.
I'm wondering if there is a way to only return "x" for the last Sales column that has "Title Transfer"?
For example, assuming these events happen in the same row where:
1st Sales column has Green and 51st column remain blank
2nd Sales column has Title Transfer and 51st column has x
3rd Sales column has Rollup and 51st column turns blank
4th Sales column has Red and 51st column remains the same
5th Sales column has Title Transfer and 51st column now has x and so on
FYI:
1st Sales column is column N
2nd Sales column is column R
3rd Sales column is column V
4th Sales column is column Z
5th Sales column is column AD
6th Sales column is column AH
7th Sales column is column AL
8th Sales column is column AP
Really sorry that I couldn't include a sample here since my work laptop doesn't allow me to download any add-in, including XL2BB.
Please advise how I can make it work that way. Any help is highly appreciated! Thanks a lot!
I tried the following code to do: If any Sales cells have "Title Transfer" then the 51st column would have an "x".
I have 8 columns named "Sales" in total. The 5st column is named "Title Transfer".
VBA Code:
Option Explicit
Public Const colTTransfer As Long = 51
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lastColumn As Long
Dim counter As Long
lastColumn = Me.Cells(1, Me.Columns.Count).End(xlToLeft).Column
If Me.Cells(1, Target.Column).Value = "Sales" Then
For counter = 1 To lastColumn
If Me.Cells(Target.Row, counter).Value = "Title Transfer" Then
Me.Cells(Target.Row, colTTransfer).Value = "x"
End If
Next counter
End If
End Sub
However, I realised there was more to my original purpose and the above codes weren't flexible.
I'm wondering if there is a way to only return "x" for the last Sales column that has "Title Transfer"?
For example, assuming these events happen in the same row where:
1st Sales column has Green and 51st column remain blank
2nd Sales column has Title Transfer and 51st column has x
3rd Sales column has Rollup and 51st column turns blank
4th Sales column has Red and 51st column remains the same
5th Sales column has Title Transfer and 51st column now has x and so on
FYI:
1st Sales column is column N
2nd Sales column is column R
3rd Sales column is column V
4th Sales column is column Z
5th Sales column is column AD
6th Sales column is column AH
7th Sales column is column AL
8th Sales column is column AP
Really sorry that I couldn't include a sample here since my work laptop doesn't allow me to download any add-in, including XL2BB.
Please advise how I can make it work that way. Any help is highly appreciated! Thanks a lot!