PC Review


Reply
Thread Tools Rate Thread

Code needs your help

 
 
=?Utf-8?B?anVzdG1l?=
Guest
Posts: n/a
 
      4th Jan 2007
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.
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      4th Jan 2007
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" <(E-Mail Removed)> wrote in message
news:8BABE8BC-F6B3-4D0C-963F-(E-Mail Removed)...
> 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.



 
Reply With Quote
 
=?Utf-8?B?anVzdG1l?=
Guest
Posts: n/a
 
      4th Jan 2007
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.


 
Reply With Quote
 
=?Utf-8?B?anVzdG1l?=
Guest
Posts: n/a
 
      4th Jan 2007
It was the special cells designation that was preventing me from finding
blanks, originally!
 
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
Linq to XML--Are there code examples that make Linq as easy as SQL? Or how can I convert ths simple pseudo code into real code? Reece Microsoft C# .NET 4 10th Dec 2008 03:13 AM
ATI Radeon Drivers - Code 43, Code 37 & Code 10 =?Utf-8?B?SmFrZQ==?= Windows Vista Hardware 14 29th Aug 2006 05:50 AM
ATI Display Drivers - Code 43, Code 37, Code 10 Jake Windows Vista Hardware 2 8th Jul 2006 04:00 PM
what is the difference between code inside a <script> tag and code in the code-behind file? keithb Microsoft ASP .NET 1 29th Mar 2006 02:00 AM
[New] Zipoid - ZIP Code, City Name and Area Code Lookup - Zip Code to Zip Code Distance Calculation Mel Freeware 0 22nd Jul 2005 04:13 PM


Features
 

Advertising
 

Newsgroups
 


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