LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 983
Default VBA n00b :\

You need to set a flag when you have found a name

blnFoundName = false
Sub SuperHighlight()
Dim strName As String
Dim blnFoundName as boolean

blnFoundName = false
strName = InputBox("Type in the name of the sales representative
you wish to be highlighted")

Application.Goto Reference:="FirstDate"
Do Until ActiveCell = "" or blnFoundName = true
ActiveCell.Range("A1:D1").Select
If ActiveCell.Offset(0, 1) = strName Then
Selection.Font.ColorIndex = 3
blnFoundName = true
End If
ActiveCell.Offset(1, 0).Select

Loop
if blnFoundName = false then
msgbox strName & " not Found"
endif

If strName = "" Then MsgBox "User Not Found Re-Type Name"


End Sub


"skattyd" wrote: Sub SuperHighlight()
Dim strName As String

strName = InputBox("Type in the name of the sales representative
you wish to be highlighted")

Application.Goto Reference:="FirstDate"
Do Until ActiveCell = ""
ActiveCell.Range("A1:D1").Select
If ActiveCell.Offset(0, 1) = strName Then
Selection.Font.ColorIndex = 3
End If
ActiveCell.Offset(1, 0).Select

Loop

If strName = "" Then MsgBox "User Not Found Re-Type Name"


End Sub




i'm just starting out with VBA i have to write a code to search through
a database in excel and highlight people in red that you put into the
input box. How can i make it if the persons name is not found come up
with a message box stating so and if it is found to just end. here is
my code so for i just cant figure it out please help!!




--
skattyd
------------------------------------------------------------------------
skattyd's Profile: http://www.excelforum.com/member.php...o&userid=16545
View this thread: http://www.excelforum.com/showthread...hreadid=313946


 
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
Excel n00b, how to do basic math functions Omohundro Excel Worksheet Functions 7 October 29th 07 07:39 PM
n00b Q - Regarding the inner workings of pivottables S Davis Excel Worksheet Functions 2 November 10th 06 08:44 PM
What does hitting Ctrl + Shift + Enter to enter a formula do??? Help a n00b out. qwopzxnm Excel Worksheet Functions 2 October 20th 05 09:06 PM


All times are GMT +1. The time now is 03:38 AM.

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"