Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Identify cells based on format

Hello there,

In several occassions I've tried unsuccessfully to identify specific cells
based on their contents. In this particular case I'm trying to identify (and
delete) the cells of a column that contain numbers instead of text. I tried
using the format property but I didn't get too far. Can anyone help?

Thanks!

AP.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Identify cells based on format

Depends on what you mean by number. You can test the contents with
IsNumeric which will have a true result for any kind of number such as -1.7.
If you want to limit the test to something more specific such as integers,
look at the "like" function.

HM

"Alejandro" wrote in message
...
Hello there,

In several occassions I've tried unsuccessfully to identify specific cells
based on their contents. In this particular case I'm trying to identify
(and
delete) the cells of a column that contain numbers instead of text. I
tried
using the format property but I didn't get too far. Can anyone help?

Thanks!

AP.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Identify cells based on format

Hi

Maybe this ?

Sub DeleteNumbers()
For Each cell In Columns("A").Cells
If IsNumeric(cell) = True Then
cell.ClearContents
End If
Next
End Sub

Regards,
Per

"Alejandro" skrev i meddelelsen
...
Hello there,

In several occassions I've tried unsuccessfully to identify specific cells
based on their contents. In this particular case I'm trying to identify
(and
delete) the cells of a column that contain numbers instead of text. I
tried
using the format property but I didn't get too far. Can anyone help?

Thanks!

AP.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Identify cells based on format

Thanks for the help. Something still doesn't work. When I debug the code I
get an error message stating that cell is a variable not defined. This is the
code I've got:

By the way, I need to delete the whole row, not only the cell. Thanks!!

Sub Macro1()

Dim X, Y As Integer

Y = 0
While Y <= 500
For Each cell In Columns("A").Cells
If IsNumeric(cell) = False Then
X = cell.Row
Worksheets("Sheet1").Rows(X).Delete
Else
cell.Offset(1, 0).Select
End If
Next
Y = Y + 1
Wend

End Sub

"Per Jessen" wrote:

Hi

Maybe this ?

Sub DeleteNumbers()
For Each cell In Columns("A").Cells
If IsNumeric(cell) = True Then
cell.ClearContents
End If
Next
End Sub

Regards,
Per

"Alejandro" skrev i meddelelsen
...
Hello there,

In several occassions I've tried unsuccessfully to identify specific cells
based on their contents. In this particular case I'm trying to identify
(and
delete) the cells of a column that contain numbers instead of text. I
tried
using the format property but I didn't get too far. Can anyone help?

Thanks!

AP.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Identify cells based on format

Hi

Try this:

Sub Macro2()
Dim LastRow As Long
Dim RowCount As Long
Const TargetColumn As String = "A"

RowCount = Columns(TargetColumn).Rows.Count
LastRow = Cells(RowCount, TargetColumn).End(xlUp).Row
For r = LastRow To 1 Step -1
If IsNumeric(Cells(r, TargetColumn)) = False Then
Rows(r).Delete
End If
Next
End Sub

Regards,
Per

"Alejandro" skrev i meddelelsen
...
Thanks for the help. Something still doesn't work. When I debug the code I
get an error message stating that cell is a variable not defined. This is
the
code I've got:

By the way, I need to delete the whole row, not only the cell. Thanks!!

Sub Macro1()

Dim X, Y As Integer

Y = 0
While Y <= 500
For Each cell In Columns("A").Cells
If IsNumeric(cell) = False Then
X = cell.Row
Worksheets("Sheet1").Rows(X).Delete
Else
cell.Offset(1, 0).Select
End If
Next
Y = Y + 1
Wend

End Sub

"Per Jessen" wrote:

Hi

Maybe this ?

Sub DeleteNumbers()
For Each cell In Columns("A").Cells
If IsNumeric(cell) = True Then
cell.ClearContents
End If
Next
End Sub

Regards,
Per

"Alejandro" skrev i meddelelsen
...
Hello there,

In several occassions I've tried unsuccessfully to identify specific
cells
based on their contents. In this particular case I'm trying to identify
(and
delete) the cells of a column that contain numbers instead of text. I
tried
using the format property but I didn't get too far. Can anyone help?

Thanks!

AP.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Conditional format based on other cells Tonto Excel Discussion (Misc queries) 3 October 14th 09 02:50 AM
CONDITIONAL FORMAT BASED ON 2 CELLS Steve_n_KC Excel Worksheet Functions 4 May 11th 07 10:38 PM
Conditional Format based on 3 other cells. Dtown Dawg Excel Discussion (Misc queries) 2 September 11th 06 10:39 PM
how do i format a cell based on format of a range of cells? Chris Hardick Excel Discussion (Misc queries) 2 April 3rd 06 08:54 AM
how do you format a row of cells based upon a value in another ce. hazenb1 Excel Discussion (Misc queries) 1 December 9th 04 04:22 AM


All times are GMT +1. The time now is 01:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"