Solved

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

Posted on 2011-09-04
2
211 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

733 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