+ Reply to Thread
Results 1 to 5 of 5

VBA Code Delete Cell Content if met criteria " "

  1. #1
    Registered User
    Join Date
    04-24-2014
    Location
    Utrecht, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    6

    VBA Code Delete Cell Content if met criteria " "

    Hello,

    Could someone help me to a VBA code tot delete cell contents within a range when a specific criteria is met.

    Range = A11:L136
    Criteria = " "

    I think I have to explain, that the " " is the outcome of an If formula. Excel sees the " " as an infinte number and text as well. In Cell A11 is a formula with the outcome " " I have already set up an VBA code to copy and paste values (skip blanks) in cell A11. So the content of cell A11 is no longer a formlua but simply " ". By the way when I stand in cell A11 you will see nothing in the formula bar. Excel shows nothing, but when you use ISTEXT or =A11>1E+100 on cell A11 the outcome of the formula is TRUE.

    I hope someone can help me with this.

  2. #2
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Code Delete Cell Content if met criteria " "

    I'd suggest uploading your workbook so we can see what is in the cells. Click go advanced and then attachments to upload your workbook. Get rid of any sensitive data and just put a few lines as an example.

  3. #3
    Registered User
    Join Date
    04-24-2014
    Location
    Utrecht, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: VBA Code Delete Cell Content if met criteria " "

    Hello ragulduy.

    I have uploaded the file. Sheet 2 needs to be exported to an other workbook in order to be able to send it by email without al the other information in the workbook. This is already covered with a VBA code in Module 1. In the same module I have also added a code to eliminate the blank rows in sheet 2. This works great except for the blanks with the “ ” content which applies to all the blank cells.

    In below code I want to add a code (in the bold marked field) which delete the “ ” content in the blanks rows. Then in my opinion the problem would be solved.


    Sub Exporteren()

    Sheets("Sheet 2").Select
    Sheets("Sheet 2").Copy
    Cells.Select
    Selection.Copy
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A11").Select


    ' Here I want to ad a VBA code to delete the contents if the criteria " " is met. then below VBA should work



    ActiveSheet.UsedRange.Select
    'Deletes the entire row within the selection if the ENTIRE row contains no data.
    Dim i As Long
    'Turn off calculation and screenupdating to speed up the macro.
    With Application
    .Calculation = xlCalculationManual
    .ScreenUpdating = False
    'Work backwards because we are deleting rows.
    For i = Selection.Rows.Count To 1 Step -1
    If WorksheetFunction.CountA(Selection.Rows(i)) = 0 Then
    Selection.Rows(i).EntireRow.Delete
    End If
    Next i
    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True


    End With
    End Sub
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: VBA Code Delete Cell Content if met criteria " "

    Please Login or Register  to view this content.
    works for me..

  5. #5
    Registered User
    Join Date
    04-24-2014
    Location
    Utrecht, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: VBA Code Delete Cell Content if met criteria " "

    Works for me too Thank you very much. I would have never come up with that.

    Quote Originally Posted by ragulduy View Post
    Please Login or Register  to view this content.
    works for me..

+ 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] Code that copies row of data to another sheet based on text "Complete"/"Delete"
    By Dremzy in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 04-20-2014, 05:51 PM
  2. Replies: 2
    Last Post: 04-20-2014, 11:18 AM
  3. Replies: 3
    Last Post: 04-16-2014, 10:00 AM
  4. delete cell content if it's "#n/a"
    By daveyc18 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-24-2013, 09:22 AM
  5. VBA Code- Move/Split cell content based on ","
    By Langer101 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 12-19-2012, 11:37 AM

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