LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 48
Default Msgbox Based on Cell Content ???

On Jul 23, 3:58*pm, Dave Peterson wrote:
I missed that last colorindex in your original code:

Option Explicit
Sub ValDataN()
* * Dim myCell As Range
* * Dim myRng As Range
* * Dim LastRow As Long
* * Dim wks As Worksheet
* * Dim ErrStr As String
* * Dim HowManyErrors As Long

* * ErrStr = "Needs Dept ID"
* * Set wks = ActiveSheet

* * With wks
* * * * .Unprotect
* * * * LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
* * * * Set myRng = .Range("N12", .Cells(LastRow, "N"))

* * * * For Each myCell In myRng.Cells
* * * * * * myCell.Interior.ColorIndex = xlNone
* * * * * * If Len(myCell.Value) 0 _
* * * * * * *And Len(myCell.Value) < 6 Then
* * * * * * * * myCell.Interior.ColorIndex = 3
* * * * * * End If

* * * * * * Select Case myCell.Offset(0, -3).Value
* * * * * * * * Case 100000 To 330000, 939001 To 939002
* * * * * * * * * * myCell.ClearContents
* * * * * * * * Case 400000 To 799999, Is = 940000
* * * * * * * * * * If myCell.Value = "" Then
* * * * * * * * * * * * myCell.Value = ErrStr
* * * * * * * * * * End If
* * * * * * End Select
* * * * Next myCell
* * * * .Protect
* * End With

* * HowManyErrors = Application.CountIf(myRng, ErrStr)
* * If HowManyErrors 0 Then
* * * * MsgBox "Please fix: " & HowManyErrors & " records!" _
* * * * * * * * * * & vbLf & "Search for: " & ErrStr
* * End If
End Sub

Ron wrote:

<<snipped





Hi Dave, thank you. *Wow! what a great interpretation This code is
hot.... only one problem. *Works perfect first time through, however
When I run it a second time the code applys interior color to a blank
cell that is in case 100000 To 330000, 939001 To 939002. * *Deletes
Dept ID like it should, however if I run it again it will highlight
the blank cells created by case 1. *Any suggestions? *Thank you, Ron


The second case must have a Dept ID and that's working perfect


Select Case myCell.Offset(0, -3).Value
* * * * * * * * Case 100000 To 330000, 939001 To 939002
* * * * * * * * * * myCell.ClearContents
* * * * * * * * Case 400000 To 799999, Is = 940000
* * * * * * * * * * If myCell.Value = "" Then
* * * * * * * * * * * * myCell.Value = ErrStr
* * * * * * * * * * End If


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Hi Dave, when I run it for the first time on a worksheet it finds
case 2 scnarios and adds Needs Dept ID, but does not color the cell
red. When I run it the second time it finds case 2 scnario and colors
them red. Any way to get it to color the cell red the first time
through. Other than that it works great and thank you for your
assistance and follow ups. Ron
 
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
sum based on PARTIAL content of another cell [email protected] Excel Worksheet Functions 4 April 6th 07 03:07 PM
sum if based on PARTIAL content of another cell [email protected] Excel Worksheet Functions 1 April 6th 07 05:19 AM
Delete Row based off cell content Chuck Neal Excel Discussion (Misc queries) 3 March 29th 06 08:52 PM
msgbox based on cell entry Robert Excel Programming 4 June 3rd 05 09:00 PM
Add name by vba based on cell content christobal Excel Programming 3 April 1st 04 12:00 PM


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

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

About Us

"It's about Microsoft Excel"