Hello,
I need your assistance with a vba code. I don't know how to change it to do what I need unfortunately.
To make things easier, I will upload my excel file here.
Please check the code below:
Sub Worksheet_Change(ByVal Target As Range)
If Not Intersect(Target, Range("H14:H25")) Is Nothing Then
Dim ws2 As Worksheet: Set ws2 = Sheet2
Dim ws3 As Worksheet: Set ws3 = Sheet3
x = Application.Match(Range("B" & Target.Row), ws2.Range("B4:B500"), 0)
If IsNumeric(x) Then
For i = 7 To Columns.Count
If ws2.Cells(1, i).EntireColumn.Hidden = False Then
ws2.Range("G" & x + 3).Offset(0, i - 7) = ws2.Range("G" & x + 3).Offset(0, i - 7).Value2 + CStr(Target.Value)
GoTo MyEnd
End If
Next i
End If
End If
MyEnd:
End Sub
Display More
My excel file has at the moment 9 sheets but it will have more sheets similar to the sheets 6 - sheet 9.
What I want is to make the vba code that's added into Sheet 3, to show the result also in Sheet 6-sheet x, (where x is the last sheet I will add), based on 1 condition.
Example:
If WS3: B14 = 13396, and H14 = whatever,
Then show the result of the vba code in WS2, G329 ( 329 being the matching row of the 13396 code inside WS2.)
But also, if I change the B14 with B14 = 12375, and H14 = whatever,
Then show the result of the vba code in WS2, G98 ( 98 being the matching row of the 12375 code inside WS2).
What I said above is what the code does now. I need it to also do this:
If WS3: B14 = 13396, and H14 = whatever, and G9=Sheet6 (It won't actually say sheet 6, but it will be a data validation list)
Then show the result of the vba code in WS2, G329 ( 329 being the matching row of the 13396 code inside WS2.)
And also show the result of the vba code in WS6, F6 (6 being the matching row of the 13396 code inside WS6)
If WS3: B14 = 13396, and H14 = whatever, and G9=Sheet8
Then show the result of the vba code in WS2, G329 ( 329 being the matching row of the 13396 code inside WS2.)
And also show the result of the vba code in WS8, F6 (6 being the matching row of the 13396 code inside WS8)
If G9 = empty, then the vba code should do just the first part where the result is shown only in WS2.
I want to mention that the value of 13396 inside Sheet6 to Sheet x, won't be always at the same row.
1336 can be in Sheet 6 in row 6, but in Sheet 15 can be in row 25. The fact that both Sheet 6 and Sheet 8 has the code 1336 in B6 is a coincidence.
Basically, I want the code to show the results in ws2 everytime, but also to match the row in the other worksheets and based on the condition that G9=whatever, to show the result in the specified sheet too, at the correct row.
I think that it is important to say, I don't need the hidden columns part for the other sheets. Just for WS2 as it is now, but if it's easier to let it there, then let it there.
Any help with this issue will be much appreciated.
Thank you
This is what I need the code to do.