Hi,
I've got a quick question here.
I have some data that looks like this
%Pct Tag Tag Tag Note
.5 SS
.02 CS REVIEW
.03 BY PARTIAL
.9
.01 SL
I'm looking to hide any column that doesn't have any cells that fit the following logic based on this logic:
if {row contains (SL or CS or SS or BY) AND abs(%Pct)>.05} or {row contains row contains (SL or CS or SS or BY) AND Note is (REVIEW or PARTIAL or REJECT)}
In this case, the 3rd column would get hidden because the only cell containing a value does not meet the parameters.
my current VBA looks like this, but I am getting an error on the IF statement:
Sub HideRows()
Dim col As Integer
Dim row As Integer
Dim i As Integer
Dim MyRange As Variant
Dim Pct As Variant
Dim Note As Variant
Dim x As Integer
Dim y As Integer
col = ActiveSheet.UsedRange.Columns.Count - 5
row = ActiveSheet.Range("A" & Rows.Count).End(xlUp).row
Set Pct = ActiveSheet.Range(Cells(2, 2), Cells(2, col))
Set Note = ActiveSheet.Range(Cells(2, col + 3), Cells(row, col + 3))
For i = 3 To 3
Set MyRange = ActiveSheet.Range(Cells(2, i), Cells(row, i))
For x = 1 To col
If MyRange(x) = (("SL" Or "CS" Or "SS" Or "BY") And Abs(Pct(x) > 0.05)) Or (MyRange(x) = ("SL" Or "CS" Or "SS" Or "BY") And Note(x) = ("PARTIAL" Or "REVIEW" Or "REJECT")) Then
y = y + 1
End If
Next x
If y = 0 Then
Columns(i).Hidden = True
Next i
End Sub
I've got a quick question here.
I have some data that looks like this
%Pct Tag Tag Tag Note
.5 SS
.02 CS REVIEW
.03 BY PARTIAL
.9
.01 SL
I'm looking to hide any column that doesn't have any cells that fit the following logic based on this logic:
if {row contains (SL or CS or SS or BY) AND abs(%Pct)>.05} or {row contains row contains (SL or CS or SS or BY) AND Note is (REVIEW or PARTIAL or REJECT)}
In this case, the 3rd column would get hidden because the only cell containing a value does not meet the parameters.
my current VBA looks like this, but I am getting an error on the IF statement:
Sub HideRows()
Dim col As Integer
Dim row As Integer
Dim i As Integer
Dim MyRange As Variant
Dim Pct As Variant
Dim Note As Variant
Dim x As Integer
Dim y As Integer
col = ActiveSheet.UsedRange.Columns.Count - 5
row = ActiveSheet.Range("A" & Rows.Count).End(xlUp).row
Set Pct = ActiveSheet.Range(Cells(2, 2), Cells(2, col))
Set Note = ActiveSheet.Range(Cells(2, col + 3), Cells(row, col + 3))
For i = 3 To 3
Set MyRange = ActiveSheet.Range(Cells(2, i), Cells(row, i))
For x = 1 To col
If MyRange(x) = (("SL" Or "CS" Or "SS" Or "BY") And Abs(Pct(x) > 0.05)) Or (MyRange(x) = ("SL" Or "CS" Or "SS" Or "BY") And Note(x) = ("PARTIAL" Or "REVIEW" Or "REJECT")) Then
y = y + 1
End If
Next x
If y = 0 Then
Columns(i).Hidden = True
Next i
End Sub