Row 1

S

smandula

In this Macro, cells are highlighted, if occupied below Row 1 by Input.
Problem is: How do you color a cell in Row 1 with the same color as
these cells that occupied below Row 1.

And to leave Row 1 alone if there is no occupancy.
------------------------------------------------

Sub SearchWorkbook()
Dim Wksh As Worksheet
Dim FindString As String
Dim Msgtext As String

Msgtext = "The string was found; do you want to continue
searching?"
Prompt = "Enter the string to search for"
Title = "Find for All Sheets"

' Display the Input Box
On Error Resume Next

FindString = Application.InputBox(Prompt:=Prompt, _
Title:=Title, Type:=2) 'Text to find (string)


If FindString = "" Then
MsgBox "Canceled."
End 'exit the macro
End If


For Each Wksh In ActiveWorkbook.Worksheets(1)
With Worksheets(1).Range("B2:AX20")
Set c = .Find(FindString, LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False)
If Not c Is Nothing Then
firstAddress = c.Address
Wksh.Activate
Do
c.Interior.ColorIndex = 17
c.Select

Reply = MsgBox(Msgtext, vbYesNo, Title)
If Reply = vbNo Then End
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top