+ Reply to Thread
Results 1 to 11 of 11

isempty function is not working to show value if cell is empty

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    isempty function is not working to show value if cell is empty

    Hi,

    In the attached file the VBA is a isempty function to display the following.

    1. if column E shows completed and if column K has a date , in column J its supposed to show as Yes.
    2. if column E shows completed and if column K is empty, in column J its supposed to show as No.

    Item 1 is working but item 2 is not working.

    Additionally if i could get some advice to add

    3. if column E shows open and if column K is empty, in column J its supposed to show as Open.
    4. if column E shows cancelled and if column K is empty, in column J its supposed to show as cancelled.
    Attached Files Attached Files

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,080

    Re: isempty function is not working to show value if cell is empty

    Try:
    Sub report()
        Application.ScreenUpdating = False
        Dim LastRow As Long, status As Range
        LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
        For Each status In Range("E2:E" & LastRow)
            Select Case status.Value
                Case "Completed"
                    If status.Offset(, 6) <> "" Then
                        status.Offset(, 5) = "Yes"
                    ElseIf status.Offset(, 6) = "" Then
                        status.Offset(, 5) = "No"
                    End If
                Case "Open"
                    If status.Offset(, 6) = "" Then
                        status.Offset(, 5) = "Open"
                    End If
                Case "Cancelled"
                    If status.Offset(, 6) = "" Then
                        status.Offset(, 5) = "Cancelled"
                    End If
            End Select
        Next status
        Application.ScreenUpdating = True
    End Sub
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  3. #3
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    Re: isempty function is not working to show value if cell is empty

    Hi Mumps,

    The code worked to the request but can i check how do i integrate the below of the code in to your code as well. This section copies over data from Sheet2.

        e = Worksheets("Sheet2").UsedRange
        r = Worksheets("Sheet1").UsedRange
        
        For i = 3 To UBound(e)
            For j = 4 To UBound(r)
                If Not IsEmpty(e(i, 2)) Then
                    If e(i, 2) = r(j, 4) Then
                        r(j, 11) = e(i, 5)
                        r(j, 12) = e(i, 6)

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,080

    Re: isempty function is not working to show value if cell is empty

    Do you want this to happen only when column J in Sheet1 ="Yes"?

  5. #5
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    Re: isempty function is not working to show value if cell is empty

    Hi Mumps,

    Yes. The data will be copied over if column J is yes. Can i also check how can i get the macro to run automatically after i have pasted the data instead of pressing the run macro button manually. Do let me know if need to provide more samples.

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,080

    Re: isempty function is not working to show value if cell is empty

    When you say
    run automatically after i have pasted the data
    do you mean you will be pasting data in column E (Status)? In other words, will you be pasting "Completed", "Open" and "Cancelled" into column E? There is another approach that you might consider. You could put a drop down list in column E where you could select "Completed", "Open" or "Cancelled" and upon selection, the macro would run automatically. Would that work for you?

  7. #7
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    Re: isempty function is not working to show value if cell is empty

    Hi Mumps. Yes that will be correct. The data will constantly be pasted (Update) and column E will have either of these 3 statues. Yes, the drop down will work for me.

  8. #8
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,080

    Re: isempty function is not working to show value if cell is empty

    Which of the two approaches do you want to use, the pasting approach or the drop down approach?

  9. #9
    Forum Contributor
    Join Date
    09-30-2014
    Location
    Singapore
    MS-Off Ver
    2010
    Posts
    266

    Re: isempty function is not working to show value if cell is empty

    I will ultimately need to paste the data but can i check if i paste the data which is within these 3 statues in the drop down list in these column, will it promt an error on the vba. I guess if it does then I will have to take the pasting approach as its a lot of data and it will take a longer time for me to individually indicate the status i guess.

  10. #10
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,080

    Re: isempty function is not working to show value if cell is empty

    I think we will have to use only the "paste" option because if there are drop downs in column E, they will be deleted when you paste in the data. Try:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Intersect(Target, Range("E:E")) Is Nothing Then Exit Sub
        Dim status As Range
        For Each status In Target
            Select Case status.Value
                Case "Completed"
                    If status.Offset(, 6) <> "" Then
                        status.Offset(, 5) = "Yes"
                    ElseIf status.Offset(, 6) = "" Then
                        status.Offset(, 5) = "No"
                    End If
                Case "Open"
                    If status.Offset(, 6) = "" Then
                        status.Offset(, 5) = "Open"
                    End If
                Case "Cancelled"
                    If status.Offset(, 6) = "" Then
                        status.Offset(, 5) = "Cancelled"
                    End If
            End Select
        Next status
    End Sub

  11. #11
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,080

    Re: isempty function is not working to show value if cell is empty

    I forgot to mention that the macro must go into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Paste the data into column E.

+ 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. [SOLVED] ISEMPTY in If condition is empty not woking
    By jpbisani in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-19-2018, 07:41 AM
  2. [SOLVED] Show empty cells (with formulas) as gaps not working
    By mioakim in forum Excel Charting & Pivots
    Replies: 10
    Last Post: 08-08-2018, 09:18 AM
  3. [SOLVED] excel 2010 empty a cell according to other cells (without Deleting them just show empty)
    By pavlos_x in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-11-2015, 01:46 PM
  4. Do until isEmpty and isBold - working 75%
    By DadaaP in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-24-2013, 12:47 PM
  5. [SOLVED] If Not IsEmpty() Not Working Properly
    By jjcgirl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-19-2013, 02:09 PM
  6. Using if function to show blank when cell in other sheet is empty
    By Billznik in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 08-08-2006, 10:46 PM
  7. IsEmpty() Returns False in empty cells
    By John Hutchins in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-29-2005, 10:07 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