Praveen Kumar82
New Member
- Joined
- Oct 15, 2018
- Messages
- 2
Hi All,
I am new in excel macro and stuck while creating a sheet.
I have a excel where there are 2000 columns and i have to filter the data using column "test case name - Column D". once the filter is set then the selected rows need to colored and another column should be added in last with "ok" (in selected columns only).
I have searched the same in forum and get some help and used the code but complete sheet of getting colored instead of selected rows.
below is the full code.
Sub TestCase_Conditions()
Dim testvalue1
Dim Value1
Dim Rng1
Value1 = "tbAccFundCorrSumSoli"
With Worksheets("Analyze").Range("H:H")
Set Rng1 = .Find(What:=Value1, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng1 Is Nothing Then
Call Set_Color
End If
'
End With
End Sub
Sub Set_Color()
Set CritRange = Range(ActiveCell, ActiveCell.End(xlDown))
Worksheets("Analyze").Activate
Set DataRange = Worksheets("Analyze").Range("A2:J" & Rows.Count).End(xlUp).SpecialCells(xlCellTypeVisible)
DataRange.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=CritRange
With ActiveSheet
Set filterRange = Worksheets("Analyze").Range("A2:J" & Rows.Count).End(xlUp).SpecialCells(xlCellTypeVisible)
filterRange.EntireRow.Interior.Color = 65535
End With
On Error GoTo 0
End Sub
Please help to solve this issue.
Thank you in advance.
I am new in excel macro and stuck while creating a sheet.
I have a excel where there are 2000 columns and i have to filter the data using column "test case name - Column D". once the filter is set then the selected rows need to colored and another column should be added in last with "ok" (in selected columns only).
I have searched the same in forum and get some help and used the code but complete sheet of getting colored instead of selected rows.
below is the full code.
Sub TestCase_Conditions()
Dim testvalue1
Dim Value1
Dim Rng1
Value1 = "tbAccFundCorrSumSoli"
With Worksheets("Analyze").Range("H:H")
Set Rng1 = .Find(What:=Value1, _
After:=.Cells(.Cells.Count), _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng1 Is Nothing Then
Call Set_Color
End If
'
End With
End Sub
Sub Set_Color()
Set CritRange = Range(ActiveCell, ActiveCell.End(xlDown))
Worksheets("Analyze").Activate
Set DataRange = Worksheets("Analyze").Range("A2:J" & Rows.Count).End(xlUp).SpecialCells(xlCellTypeVisible)
DataRange.AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:=CritRange
With ActiveSheet
Set filterRange = Worksheets("Analyze").Range("A2:J" & Rows.Count).End(xlUp).SpecialCells(xlCellTypeVisible)
filterRange.EntireRow.Interior.Color = 65535
End With
On Error GoTo 0
End Sub
Please help to solve this issue.
Thank you in advance.