Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2011-09-04
2
210 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

792 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