Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code on getting and inserting the data from another sheet can anyone have idea on how can i hide the column with duplicate entry because i just search and it is only removing duplicates not hiding the column

What I have tried:

Dim melt As Long
''Row where the data will insert
melt = 5

For x = 1 To lastRow

''Search if
If (Sheets("SchedData").Cells(x, 9) = "melt") And Sheets("SchedData").Cells(x, 1) = Sheet23.Range("Q2") Then

''Get and insert data
Sheet23.Cells(melt, 2) = Sheets("SchedData").Cells(x, 6)
Sheet23.Cells(melt, 3) = Sheets("SchedData").Cells(x, 5)
melt = melt + 1
count = count + 1

End If

Next x

''Hide all the cell within the range that is empty
For Each c In Range("B5:B20")
        If c.Value = "" Then
            c.EntireRow.Hidden = True
        Else
            c.EntireRow.Hidden = False
        End If
    Next
Posted
Updated 9-Jul-21 19:06pm
v2

1 solution

At the moment you seem to set the row as hidden, not the column so if you want to hide a column, you can use EntireColumn.Hidden.

Side-note: setting the column hidden or visible is using quite a lot of resources so instead of changing the visibility back and forth, you may want to loop through the range and decide whether to hide it or not and after the loop make the change.
 
Share this answer
 
Comments
Jonjon Candare 10-Jul-21 1:13am    
how will i find if its duplicate? then just show only one then hide the duplicate names
Wendelius 10-Jul-21 4:31am    
Could elaborate more, what is duplicate compared to what?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900