+ Reply to Thread
Results 1 to 4 of 4

Need help with hiding a row based off criteria, and deleting cell content also

  1. #1
    Registered User
    Join Date
    06-24-2013
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Cool Need help with hiding a row based off criteria, and deleting cell content also

    Hi all, this is my first time attempting any VBA at all I've had success in getting both options I want to work separately but not together.

    Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
    Select Case Range("c2")
    End Select
    If Range("c2").Value = "New Customer" Then Rows(5).Hidden = False Else Rows(5).Hidden = True
    If Range("b5:e5").Value = "" And Rows(5).Hidden = True Then Range("b5:e5").ClearContents Else Exit Sub
    End Sub

    This is what I have so far when trying to get both to work at same time.

    The end result I am looking for is the row 5 to hide and unhide based off my drop down list, which is working. Then when the row 5 is hidden to check cells in range b5:e5 for any content and if there is any to delete it.

    Run-time error '13':

    Type mismatch is currently the error I am receiving

    Any and all help is greatly appreciated. I have no deadline on this just thought it be fun to learn VBA and wanted to do some cool stuff.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help with hiding a row based off criteria, and deleting cell content also

    Hi

    how can you say:

    Please Login or Register  to view this content.
    You need to sum or add the values in the range together,

    Excel will give you an error.

  3. #3
    Registered User
    Join Date
    06-24-2013
    Location
    California, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Need help with hiding a row based off criteria, and deleting cell content also

    The values I'm looking are actually words in each cell. Should I still add them, also isn't b5:e5 mean the sum? I'm just learning this not sure of how all the Code works.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Need help with hiding a row based off criteria, and deleting cell content also

    No.

    If you want to add the text together then you need to say:

    Please Login or Register  to view this content.
    You can use concatenate within excel to join the strings together and then test if that cell is empty.

    So in Excel Enter this in A5:

    Please Login or Register  to view this content.
    then in VB:

    Please Login or Register  to view this content.
    Hope that helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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