PDA

View Full Version : [SOLVED:] VBA Code Range Issue



estatefinds
03-22-2016, 05:40 AM
I have a code in which I run that uses data in columns ABCDEF together to color certain data.

The problem I am having is with ANOTHER Code in which the CODE N_snb is only supposed to look at Data in columns BCDEF but instead it is also pulling data from Column A which is interfering with what it supposed to do. Really what is needed is to revise the code so that the N_snb code only looks at data in columns BCDEF.
Thank you!

to see what I mean take the data in column A and move it below the level of the data in Columns BCDEF but keep it in Column A then run the Code N_snb and you'll see how it supposed to work . Then replace the data back in Column A at the same level as data in columns BCDEF Then run the N_snb and you'll see the data from column A being pulled back into column AL.

PAB
03-22-2016, 06:23 AM
Hi Dennis, is it this what you are after?


Sub N_snb()
sn = Cells(9, 2).CurrentRegion

For j = 1 To UBound(sn)
For jj = 1 To UBound(sn, 2)
If InStr(c00, " " & sn(j, jj) & " ") <> 0 Then sn(j, jj) = "~"
c00 = c00 & " " & sn(j, jj) & " "
Next
Next

For j = 1 To UBound(sn)
sp = Filter(Application.Index(sn, j), "~", 0)
For jj = 1 To UBound(sn, 2)
sn(j, jj) = ""
If jj - 1 <= UBound(sp) Then sn(j, jj) = sp(jj - 1)
Next
If UBound(sp) > -1 Then c01 = c01 & " " & j
Next
sp = Application.Transpose(Split(Trim(c01)))

Cells(11, 38).Resize(UBound(sp), UBound(sn, 2)) = Application.Index(sn, sp, Array(2, 3, 4, 5, 6))
End Sub

I hope this helps!

estatefinds
03-22-2016, 07:16 AM
IT works! Thank you Very Much!!!

PAB
03-22-2016, 08:15 AM
You're welcome, thanks for the feedback.