Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Dim cell As Range
Set cell = Nothing Set cell = Cells.Find(What:="TAX-BENEFITS IN KIND", _ After:=ActiveCell, _ LookIn:=xlValues, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not cell Is Nothing Then cell.Value = "TAX IN KIND" End If Set cell = Nothing Set cell = Cells.Find(What:="SALARIES", _ After:=ActiveCell, _ LookIn:=xlValues, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not cell Is Nothing Then With Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End If Set cell = Nothing -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "mike_vr" wrote in message ... 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 |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Spot on Bob! Works like a charm, really appreciate it.
Cheers, Mike "Bob Phillips" wrote: Dim cell As Range Set cell = Nothing Set cell = Cells.Find(What:="TAX-BENEFITS IN KIND", _ After:=ActiveCell, _ LookIn:=xlValues, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not cell Is Nothing Then cell.Value = "TAX IN KIND" End If Set cell = Nothing Set cell = Cells.Find(What:="SALARIES", _ After:=ActiveCell, _ LookIn:=xlValues, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not cell Is Nothing Then With Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Range(Cells(cell.Row, 1), Cells(cell.Row, 11)).Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With End If Set cell = Nothing -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "mike_vr" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
SQL concatenation statement | Excel Discussion (Misc queries) | |||
SET statement tutorial | Excel Discussion (Misc queries) | |||
If statement | Excel Discussion (Misc queries) | |||
Do I need a sumif or sum of a vlookup formula? | Excel Worksheet Functions | |||
How do I fix a circular reference in a financial statement? | Excel Discussion (Misc queries) |