Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Code needs your help

Public Sub FindNonNumericFactories_CLEAN()

Dim myRange As Range, cell As Range
Dim EnterFactory As Variant
On Error Resume Next
With Worksheets("Sheet1")
Set myRange = .Range(.Cells(1, "A"), .Cells(Rows.Count, "A").End(xlUp)) _
..SpecialCells(xlConstants, xlTextValues)
End With
On Error GoTo 0
If myRange Is Nothing Then Exit Sub
For Each cell In myRange

If Not IsNumeric(cell.Value) Or IsEmpty(cell.Value) = "" Then
cell.Select
EnterFactory = InputBox("Enter Factory#: ")
If EnterFactory < "" Then
ActiveCell.Value = EnterFactory
End If
End If
Next

End Sub
------

This code works(!), but does not do everything I'd like it to do.

1. When it finds a cell , I can click "cancel" to ignore the cell and go to
the next one. This is great, because many times the user will want to leave
the cell as is, but I would like for the cancel button to say "ignore" and to
have a "real" cancel button to exit out of the macro. This may be too much to
ask for, but putting it out there just in case.

2. It seems to find cells with letters, symbols and spaces, but it's not
finding blanks.
Column 1 should contain only a number (positive number).
I'd like to find cells in the first column that:
a) contain any letters, symbols or other non-numeric characters
b) contain a space
c) are blank

Hope there's someone out there who can help me out.
Thanks.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Code needs your help

1 - If you need this kind of customisation, make you own userform instead of
using the Inputbox.

2 - You are currently using <IsEmpty(cell.Value) = "", which seems like a
mix of the 2 similar statements:
IsEmpty(cell.Value) = True
cell.Value = ""

Use one of these

NickHK

"justme" wrote in message
...
Public Sub FindNonNumericFactories_CLEAN()

Dim myRange As Range, cell As Range
Dim EnterFactory As Variant
On Error Resume Next
With Worksheets("Sheet1")
Set myRange = .Range(.Cells(1, "A"), .Cells(Rows.Count, "A").End(xlUp)) _
.SpecialCells(xlConstants, xlTextValues)
End With
On Error GoTo 0
If myRange Is Nothing Then Exit Sub
For Each cell In myRange

If Not IsNumeric(cell.Value) Or IsEmpty(cell.Value) = "" Then
cell.Select
EnterFactory = InputBox("Enter Factory#: ")
If EnterFactory < "" Then
ActiveCell.Value = EnterFactory
End If
End If
Next

End Sub
------

This code works(!), but does not do everything I'd like it to do.

1. When it finds a cell , I can click "cancel" to ignore the cell and go

to
the next one. This is great, because many times the user will want to

leave
the cell as is, but I would like for the cancel button to say "ignore" and

to
have a "real" cancel button to exit out of the macro. This may be too much

to
ask for, but putting it out there just in case.

2. It seems to find cells with letters, symbols and spaces, but it's not
finding blanks.
Column 1 should contain only a number (positive number).
I'd like to find cells in the first column that:
a) contain any letters, symbols or other non-numeric characters
b) contain a space
c) are blank

Hope there's someone out there who can help me out.
Thanks.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Code needs your help

Thanks, Nick.

The use of IsEmpty *and* ="" was an oversight on my part (duh!). That would
solve that problem. I will look into creating a userform.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 68
Default Code needs your help

It was the special cells designation that was preventing me from finding
blanks, originally!
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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
How to assign same code inside Option button code space ?? furbiuzzu Excel Programming 1 November 21st 06 02:36 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 07:07 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"