Solved

Look for text entries in specific column, move up one cell and delete that cell

Posted on 2011-09-04
2
209 Views
Last Modified: 2012-05-12
Dear Experts:

I would like to achieve the following using VBA:

Go thru column B of the (used range of the ) active worksheet and look for text entries (numbers formatted as text do not count).
If found move up one cell and delete the contents of that cell. Do Loops.

Help is much appreciated. Thank you very much in advance.

Regards, Andreas

I have attached a sample file for your  convenience with detailed explanations.


 Loop-And-Delete.xlsx
0
Comment
Question by:AndreasHermle
2 Comments
 
LVL 18

Accepted Solution

by:
krishnakrkc earned 500 total points
ID: 36480437
Hi,

Try

Sub kTest()

    Dim k, i As Long, cAddr As String, r As Range
   
    Const StartCell As String = "B7" '<<=== adjust this to suit
   
    Set r = Range(CStr(StartCell))
   
    k = Range(r, Cells(Rows.Count, r.Column).End(xlUp))
   
    For i = 2 To UBound(k, 1)
        If Not IsNumeric(k(i, 1)) Then
            cAddr = cAddr & "," & Cells(i - 1, 1).Address(0, 0)
            If Len(cAddr) > 240 Then
                r.Range(CStr(Mid$(cAddr, 2))).ClearContents
                cAddr = vbNullString
            End If
        End If
    Next
    If Len(cAddr) > 1 Then
        r.Range(CStr(Mid$(cAddr, 2))).ClearContents
    End If

End Sub

Kris
0
 

Author Closing Comment

by:AndreasHermle
ID: 36480843
Hi Kris,

great job. Works like a charm. Thank you very much for your professional help. Regards,  Andreas
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question