Results 1 to 1 of 1

Thread: Formatting problems

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2005
    Posts
    1

    Formatting problems

    I'm trying to get some existing code to a VB 6 project to work for me and I'm rather unsuccessful. The following is the Function:

    VB Code:
    1. Function BoldManyByMatch(strFind As String, OExcel As Excel.Application) As Boolean
    2.     Dim cellRow As Integer
    3.    
    4.     With OExcel
    5.         cellRow = .ActiveCell.Row
    6.         .Cells.Find(What:=strFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
    7.             SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
    8.    
    9.       Do While cellRow < .ActiveCell.Row
    10.         .Range(Selection, Selection.End(xlToRight)).Select
    11.         .Selection.Font.FontStyle = "Bold"
    12.         .Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    13.         .Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    14.         .Selection.Borders(xlEdgeLeft).LineStyle = xlNone
    15.    
    16.         With Selection.Borders(xlEdgeTop)
    17.             .LineStyle = xlContinuous
    18.             .Weight = xlMedium
    19.             .ColorIndex = xlAutomatic
    20.         End With
    21.    
    22.         With Selection.Borders(xlEdgeBottom)
    23.             .LineStyle = xlContinuous
    24.             .Weight = xlMedium
    25.             .ColorIndex = xlAutomatic
    26.         End With
    27.    
    28.         cellRow = .ActiveCell.Row
    29.        
    30.         .Cells.Find(What:=strFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlPart, _
    31.             SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False).Activate
    32.         Debug.Print .ActiveCell.Row
    33.       Loop
    34.     End With
    35.     BoldManyByMatch = True
    36.     Exit Function
    37.  
    38. End Function

    I search for a string "COMBO" on excel and it borders and bolds the current and remaining cells. Unfortunatly it only captures whats right of the current field and I also need one field to the left(ie from b2:b18 and I want b1:b18). Any help with this would be much appreciated. Oh I've also tried the same code with .Range(Selection, Selection.End(x1ToLeft)).Select and that doesn't work for me. Thanks!
    Last edited by si_the_geek; Oct 24th, 2005 at 03:37 PM. Reason: added VBCode formatting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width