PC Review


Reply
Thread Tools Rate Thread

Deleting cells if there is an alphabetical character in it

 
 
N1KO
Guest
Posts: n/a
 
      6th Nov 2008
Here is some code i've used to copy values from cell to cell and i now want
to make all the cells with letters (a, b, c, etc) in them blank. For the life
of me i can't make any that actually start with a number become blank.

Help would be appreciated.

Sub Codes()

Sheets("Town Pubs Cross Ref report").Activate
Range("B3").Select
Do
If ActiveCell.Value = "" Then
ActiveCell.Value = ActiveCell.Offset(0, -1)
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Row = 21568
End Sub

Sub Delete()

Sheets("Town Pubs Cross Ref report").Activate
Range("B3").Select
Do
If ActiveCell.Value <> "?????" Then
ActiveCell.Value = ""
Cancel = True
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Row = 21568
End Sub

So basically i want to clear any cell in column B that has a letter in it
regardless whether it has a number in it.
 
Reply With Quote
 
 
 
 
Bernie Deitrick
Guest
Posts: n/a
 
      6th Nov 2008
N1KO,

Try deleting any cell with a string value in it:

Sheets("Town Pubs Cross Ref report").Range("B3:B21568").SpecialCells(xlCellTypeConstants,
2).ClearContents


HTH,
Bernie
MS Excel MVP


"N1KO" <(E-Mail Removed)> wrote in message
news:3D699D8F-AFDE-4994-A42E-(E-Mail Removed)...
> Here is some code i've used to copy values from cell to cell and i now want
> to make all the cells with letters (a, b, c, etc) in them blank. For the life
> of me i can't make any that actually start with a number become blank.
>
> Help would be appreciated.
>
> Sub Codes()
>
> Sheets("Town Pubs Cross Ref report").Activate
> Range("B3").Select
> Do
> If ActiveCell.Value = "" Then
> ActiveCell.Value = ActiveCell.Offset(0, -1)
> End If
> ActiveCell.Offset(1, 0).Select
> Loop Until ActiveCell.Row = 21568
> End Sub
>
> Sub Delete()
>
> Sheets("Town Pubs Cross Ref report").Activate
> Range("B3").Select
> Do
> If ActiveCell.Value <> "?????" Then
> ActiveCell.Value = ""
> Cancel = True
> End If
> ActiveCell.Offset(1, 0).Select
> Loop Until ActiveCell.Row = 21568
> End Sub
>
> So basically i want to clear any cell in column B that has a letter in it
> regardless whether it has a number in it.



 
Reply With Quote
 
Mike H
Guest
Posts: n/a
 
      6th Nov 2008
Hi,

Try this

Sub Delete()
Sheets("Town Pubs Cross Ref report").Activate
Range("B3").Select
Do
If Not IsNumeric(ActiveCell.Value) Then
ActiveCell.ClearContents
End If
ActiveCell.Offset(1, 0).Select
Loop Until ActiveCell.Row = 21568
End Sub


Mike

"N1KO" wrote:

> Here is some code i've used to copy values from cell to cell and i now want
> to make all the cells with letters (a, b, c, etc) in them blank. For the life
> of me i can't make any that actually start with a number become blank.
>
> Help would be appreciated.
>
> Sub Codes()
>
> Sheets("Town Pubs Cross Ref report").Activate
> Range("B3").Select
> Do
> If ActiveCell.Value = "" Then
> ActiveCell.Value = ActiveCell.Offset(0, -1)
> End If
> ActiveCell.Offset(1, 0).Select
> Loop Until ActiveCell.Row = 21568
> End Sub
>
> Sub Delete()
>
> Sheets("Town Pubs Cross Ref report").Activate
> Range("B3").Select
> Do
> If ActiveCell.Value <> "?????" Then
> ActiveCell.Value = ""
> Cancel = True
> End If
> ActiveCell.Offset(1, 0).Select
> Loop Until ActiveCell.Row = 21568
> End Sub
>
> So basically i want to clear any cell in column B that has a letter in it
> regardless whether it has a number in it.

 
Reply With Quote
 
N1KO
Guest
Posts: n/a
 
      6th Nov 2008
Thanks, both answers worked perfectly.

"Mike H" wrote:

> Hi,
>
> Try this
>
> Sub Delete()
> Sheets("Town Pubs Cross Ref report").Activate
> Range("B3").Select
> Do
> If Not IsNumeric(ActiveCell.Value) Then
> ActiveCell.ClearContents
> End If
> ActiveCell.Offset(1, 0).Select
> Loop Until ActiveCell.Row = 21568
> End Sub
>
>
> Mike
>
> "N1KO" wrote:
>
> > Here is some code i've used to copy values from cell to cell and i now want
> > to make all the cells with letters (a, b, c, etc) in them blank. For the life
> > of me i can't make any that actually start with a number become blank.
> >
> > Help would be appreciated.
> >
> > Sub Codes()
> >
> > Sheets("Town Pubs Cross Ref report").Activate
> > Range("B3").Select
> > Do
> > If ActiveCell.Value = "" Then
> > ActiveCell.Value = ActiveCell.Offset(0, -1)
> > End If
> > ActiveCell.Offset(1, 0).Select
> > Loop Until ActiveCell.Row = 21568
> > End Sub
> >
> > Sub Delete()
> >
> > Sheets("Town Pubs Cross Ref report").Activate
> > Range("B3").Select
> > Do
> > If ActiveCell.Value <> "?????" Then
> > ActiveCell.Value = ""
> > Cancel = True
> > End If
> > ActiveCell.Offset(1, 0).Select
> > Loop Until ActiveCell.Row = 21568
> > End Sub
> >
> > So basically i want to clear any cell in column B that has a letter in it
> > regardless whether it has a number in it.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Test if Last Character in Column of Cells is Alpha Character Benjamin Microsoft Excel Programming 6 21st Sep 2009 06:36 PM
Finding First Alphabetical Character in a String meangene Microsoft Access Queries 2 20th May 2008 03:23 PM
Increment Alphabetical Character Dave Microsoft Access Forms 1 10th May 2006 02:12 PM
unicode - how enter alphabetical character on numeric keyboard? Lee Windows XP General 7 9th May 2006 12:13 AM
Deleting the leading character in a series of cells Alex Microsoft Excel Programming 2 24th Jun 2004 09:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:59 PM.