Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
hi i am extremely new to vba and need some help. I have recorded a macro where i perform a search within a selected range. the code ends ".activate" when it has found the specified text. now i want to apply some formatting to the cells in that row. I am happy to use the offset function (unless there is an easier way) but how do i make it so it is applied to the active cell so i can continue with "selection." i suppose i want to make it a relative reference not "Range("A13:E13").Select
does that make sense to anyone I would appreciate any help as i am an extreme novice who is losing confidence fast thank kevin |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
As usual, post your coding efforts for comments
-- Don Guillett SalesAid Software "Kevin" wrote in message ... hi i am extremely new to vba and need some help. I have recorded a macro where i perform a search within a selected range. the code ends ".activate" when it has found the specified text. now i want to apply some formatting to the cells in that row. I am happy to use the offset function (unless there is an easier way) but how do i make it so it is applied to the active cell so i can continue with "selection." i suppose i want to make it a relative reference not "Range("A13:E13").Select" does that make sense to anyone? I would appreciate any help as i am an extreme novice who is losing confidence fast. thanks kevin |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
'Didn't know if you needed the first line relative or just the stuff below
Range("B4:B18").Select Selection.Find(What:="Mr Smith", After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False).Activate With Range(Cells(ActiveCell.Row, 1), Cells(ActiveCell.Row, 5)) .Borders(xlEdgeTop).LineStyle = xlContinuous .Borders(xlEdgeTop).Weight = xlThin .Borders(xlEdgeTop).ColorIndex = xlAutomatic .Borders(xlEdgeBottom).LineStyle = xlContinuous .Borders(xlEdgeBottom).Weight = xlThin .Borders(xlEdgeBottom).ColorIndex = xlAutomatic .Font.Bold = True End With "kevin" wrote in message ... Hope this makes it a little clearer. Range("B4:B18").Select Selection.Find(What:="Mr Smith", After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False).Activate 'make relative 'Active cell.Select 'Range("A13:E13").Select With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With Selection.Font.Bold = True |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Kevin,
Is this what you want? Range("B4:B18").Find(What:="Mr Smith", _ After:=ActiveCell, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False).Activate 'make relative 'Active cell.Select 'Range("A13:E13").Select With Selection.EntireRow With .Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With .Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With .Font.Bold = True End With -- HTH Bob Phillips ... looking out across Poole Harbour to the Purbecks (remove nothere from the email address if mailing direct) "kevin" wrote in message ... Hope this makes it a little clearer. Range("B4:B18").Select Selection.Find(What:="Mr Smith", After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False).Activate 'make relative 'Active cell.Select 'Range("A13:E13").Select With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With Selection.Font.Bold = True |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If I understood you correctly, you wanted to find Mr. Smith and format a
ANOTHER cell based on that location. Sub FormatOffset() Range(Columns("b").Find("Mr Smith").address).Offset(1, 2).Select myBorders = Array(, xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight) For i = 1 To UBound(myBorders) With Selection.Borders(myBorders(i)) .LineStyle = xlContinuous .Weight = xlMedium End With Next Selection.Font.Bold = True End Sub to do range("a foundrow:e foundrow"), use this Sub Formatfoundrow() x = Columns("b").Find("Mr Smith").Row MsgBox x Range(Cells(x, 1), Cells(x, 5)).Select myBorders = Array(, xlEdgeLeft, xlEdgeTop, xlEdgeBottom, xlEdgeRight) For i = 1 To UBound(myBorders) With Selection.Borders(myBorders(i)) .LineStyle = xlContinuous .Weight = xlMedium End With Next Selection.Font.Bold = True End Sub -- Don Guillett SalesAid Software "kevin" wrote in message ... Hope this makes it a little clearer. Range("B4:B18").Select Selection.Find(What:="Mr Smith", After:=ActiveCell, LookIn:= _ xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _ xlNext, MatchCase:=False).Activate 'make relative 'Active cell.Select 'Range("A13:E13").Select With Selection.Borders(xlEdgeTop) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With With Selection.Borders(xlEdgeBottom) .LineStyle = xlContinuous .Weight = xlThin .ColorIndex = xlAutomatic End With Selection.Font.Bold = True |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Row select mode to highlight active row of active cell | Excel Discussion (Misc queries) | |||
set the background color of the current cell(active cell) | New Users to Excel | |||
referring to formula in a non active cell from active cell | Excel Discussion (Misc queries) | |||
HOW TO COPY 480 ACTIVE E-MAIL ADDRESSES CLM "G" ON AN ACTIVE EXCE. | Excel Discussion (Misc queries) | |||
Active cell plus 1 | Excel Programming |