LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 42
Default If... then... Else statement

Morning all

I have three sheets that I am trying to format. The formatting follows a
search by description and then formats that row.

In the first sheet, I have to change one description and then carry on the
formatting. But in the next two sheets that description doesn't appear.

I'm pretty inexperienced to Macros, so how would I "ask" the following
question of it?

If I find "tax-benefits in kind" change the description to "tax in kind" and
then carry on to find "salaries" and "expenses" and format them as usual
But If I can't find "tax-benefits in kind" just carry on and format
"salaries" & "expenses" as usual.

At the moment I have the following:

If Cells.Find(What:="TAX-BENEFITS IN KIND", After:=ActiveCell, LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Activate = False Then
Range("A1").Select

ElseIf Cells.Find(What:="TAX-BENEFITS IN KIND", After:=ActiveCell,
LookIn:= _
xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,
SearchDirection:=xlNext _
, MatchCase:=False).Activate = True Then
ActiveCell.Value = "TAX-BENFITS IN KIND"
Range("A1").Select

End If

Cells.Find(What:="SALARIES", After:=ActiveCell, LookIn _
:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False).Activate
Selection.End(xlToLeft).Select

thisrow = Selection.Row

With Range(Cells(thisrow, 1), Cells(thisrow, 11)).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Range(Cells(thisrow, 1), Cells(thisrow, 11)).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

So in a nutshell, I want it to find "Tax-Benefits in kind" and change to
"Tax in Kind" and then format "salaries" but if "Tax-Benefits in kind"
doesn't appear then ignore the change of name and just go on to format
salaries.

Any help would be appreciated.

Thanks!!!

Mike
 
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
SQL concatenation statement CLamar Excel Discussion (Misc queries) 0 June 29th 06 01:58 PM
SET statement tutorial Daminc Excel Discussion (Misc queries) 13 January 17th 06 04:47 PM
If statement Matt Montagliano Excel Discussion (Misc queries) 1 September 8th 05 08:47 PM
Do I need a sumif or sum of a vlookup formula? PeterB Excel Worksheet Functions 0 June 1st 05 12:23 PM
How do I fix a circular reference in a financial statement? drjayhawk25 Excel Discussion (Misc queries) 0 February 7th 05 05:19 PM


All times are GMT +1. The time now is 09:03 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"