+ Reply to Thread
Results 1 to 9 of 9

Hide a data

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Hide a data

    Hello,

    I am not sure if I needed a vba code or conditional formatting on this scenario.

    I want to hide the "200" in D4:D3000 until an entry is being entered in B4:B3000. If there is no entry in B4:B3000 then the D4:D3000 should be blank.

    Thank you in advance.
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2021
    Posts
    968

    Re: Hide a data

    Hi there,

    In cell 'D4" try:
    Formula: copy to clipboard
    =IF(B4<>"",200,"")
    and pull down.
    If your Question is answered; please mark it SOLVED. If you are happy with a member's solution, say 'Thanks' and click the 'Star' to Add Reputation.

  3. #3
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Hide a data

    Hi
    Oroos!

    Can this be done inVBA code?

  4. #4
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2021
    Posts
    968

    Re: Hide a data

    Hi again,

    Yes that can be done with VBA.
    The code is in the worksheet and is triggered when a change in column B (rows 4-3000 [can be updated..]) is changed.
    If there is anything in column B, column D will show 200. If column B value is deleted, then the 200 in column D is also cleared.

    Trust this helps.




    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim WorkRng As Range, roww As Long
        Dim rng As Range
        
        Set WorkRng = Intersect(Range("B4:B3000"), Target)
        If Not WorkRng Is Nothing Then
            Application.EnableEvents = False
                For Each rng In WorkRng
                    roww = rng.Row
                    If Not rng.Value = "" Then
                        Cells(roww, "D").Value = 200  ' <- this is the value to show in column D
                    Else
                        Cells(roww, "D").ClearContents ' <- Clear column D if column B is cleared
                    End If
                Next
            Application.EnableEvents = True
        End If
    End Sub
    Attached Files Attached Files
    Last edited by ORoos; 03-26-2023 at 01:12 AM. Reason: Added Code to post

  5. #5
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Hide a data

    Another Option...
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Range("B4:B3000")) Is Nothing Then
        Application.EnableEvents = False
        If Target.CountLarge > 1 Then
            Target.Offset(, 2).Resize(Target.Cells.Count) = ""
        ElseIf Target <> "" Then
            Target.Offset(, 2) = 200
        Else
            Target.Offset(, 2) = ""
        End If
        Application.EnableEvents = True
    End If
    End Sub
    Attached Files Attached Files
    Good Luck...
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the [★ Add Reputation] to left of post window...
    Also....Add a comment if you like!!!!
    And remember...Mark Thread as Solved...
    Excel Forum Rocks!!!

  6. #6
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Hide a data

    Thank you both!!!!

  7. #7
    Forum Guru Sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2019 | 2021
    Posts
    14,958

    Re: Hide a data

    Glad to have helped...Tx for rep +

  8. #8
    Forum Contributor
    Join Date
    10-05-2014
    Location
    CALIFORNIA
    MS-Off Ver
    2010
    Posts
    1,812

    Re: Hide a data

    Hello guys,

    I would like to add "no" in column H. No should be hide if no entry in B along with 200 which is in Column D.

    Thank you again.
    Attached Files Attached Files

  9. #9
    Valued Forum Contributor
    Join Date
    03-24-2020
    Location
    Thailand
    MS-Off Ver
    Office 2021
    Posts
    968

    Re: Hide a data

    Hi there,

    I realize your request is some weeks back (was away) below is an updated code which should do what you require.

    Private Sub Worksheet_Change(ByVal Target As Range)
        Dim WorkRng As Range, roww As Long
        Dim rng As Range
        
        Set WorkRng = Intersect(Range("B4:B3000"), Target)
        If Not WorkRng Is Nothing Then
            Application.EnableEvents = False
                For Each rng In WorkRng
                    roww = rng.Row
                    If Not rng.Value = "" Then
                        Cells(roww, "D").Value = 200  ' <- this is the value to show in column D
                        Cells(roww, "H").Value = "No"  ' <- this is the value to show in column H
                    Else
                        Cells(roww, "D").ClearContents ' <- Clear column D if column B is cleared
                        Cells(roww, "H").ClearContents ' <- Clear column H if column B is cleared
                    End If
                Next
            Application.EnableEvents = True
        End If
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 02-01-2022, 01:24 AM
  2. hide save as box and break links, normal hide aren't working
    By abrcrmdl23 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-28-2021, 07:26 PM
  3. Auto-Hide Data label if data is 0% - Percentage
    By dLhx in forum Excel General
    Replies: 8
    Last Post: 08-03-2015, 04:15 AM
  4. Hide data
    By skate1991 in forum Excel General
    Replies: 4
    Last Post: 09-03-2012, 01:33 PM
  5. VBA hide row based on pull down with button to toggle show/hide
    By myronr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2012, 06:07 PM
  6. Hide rows depending on data, BUT merge other data
    By Badvgood in forum Excel General
    Replies: 1
    Last Post: 01-18-2010, 12:05 PM
  7. Hide the data label for a data table in a chart
    By Kathy in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-23-2005, 11:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1