ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Seclect Column or Range according to Cell's Contents (https://www.excelbanter.com/excel-programming/364105-seclect-column-range-according-cells-contents.html)

Nora N

Seclect Column or Range according to Cell's Contents
 
I need a VBA macro to do the following

I have to search for a specific word say "Sunday" within a range (A7:AJ7).
When the word is found, the column containing the cell with the word
"Sunday", or a special range within the column should be shaded.

Any help would be much appreciated


Bob Phillips

Seclect Column or Range according to Cell's Contents
 
Dim oCell As Range
With Range("A7:AJ7")
Set oCell = .Find("Sunday", LookIn:=xlValues)
If Not oCell Is Nothing Then
oCell.EntireColumn.Select
End If
End With


--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Nora N" <Nora wrote in message
...
I need a VBA macro to do the following

I have to search for a specific word say "Sunday" within a range (A7:AJ7).
When the word is found, the column containing the cell with the word
"Sunday", or a special range within the column should be shaded.

Any help would be much appreciated




Nora N[_2_]

Seclect Column or Range according to Cell's Contents
 
Thank you Bob, However, I still need further assistance

What I actualy need is when the word "Sunday" is founded in a cell within
the range A7:AJ7(Suppose H7) I want range H8:H30 to be shaded in Gray.

Thank you

"Nora N" wrote:

I need a VBA macro to do the following

I have to search for a specific word say "Sunday" within a range (A7:AJ7).
When the word is found, the column containing the cell with the word
"Sunday", or a special range within the column should be shaded.

Any help would be much appreciated


Bob Phillips

Seclect Column or Range according to Cell's Contents
 
Dim oCell As Range
With Range("A7:AJ7")
Set oCell = .Find("Sunday", LookIn:=xlValues)
If Not oCell Is Nothing Then
oCell.Offset(1,0).Resize(30 - oCell.Row).Interior.Colorindex =
15
End If
End With

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Nora N" wrote in message
...
Thank you Bob, However, I still need further assistance

What I actualy need is when the word "Sunday" is founded in a cell within
the range A7:AJ7(Suppose H7) I want range H8:H30 to be shaded in Gray.

Thank you

"Nora N" wrote:

I need a VBA macro to do the following

I have to search for a specific word say "Sunday" within a range

(A7:AJ7).
When the word is found, the column containing the cell with the word
"Sunday", or a special range within the column should be shaded.

Any help would be much appreciated





All times are GMT +1. The time now is 06:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com