Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2008
    Posts
    89

    Unanswered: Select row dependant on column value?

    Hi there,

    I just started VBA today, for the single purpose to make my life easier with the massive Excel spreadsheets I need to format all the time.

    Therefore, question:
    How can I select (and then make bold) an entire row, if one value in a specific column equals a certain predefined value?

    So something like this (pseudo alert):

    Code:
    Columns("I:I").Select
    If Selection.Value <> "NONE" Then
      EntireRow.Font.Bold = True
    End if
    But it doesn't work, because (I assume) I need to loop through all rows manually and select each cell in "I:I" before I can do anything with that row?
    "My brain is just no good at being a relational Database - my relations suck real bad!"

  2. #2
    Join Date
    Mar 2008
    Posts
    89
    Ok, what I have so far looks like this:

    Code:
    Dim i As Long
           
        Columns("I:I").Select
        
       With Selection
          For i = 2 To Cells.Find(What:="*", After:=Range("I1"), LookIn:=xlValues,  LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row Step 1
            'On Error Resume Next
            If Cells(i, 9).Value <> "NONE" Then
               ActiveSheet.UsedRange.Rows(i).Font.Bold = True
            End If
          Next i
        End With
    But it looks crazy and like bad code, and worst of all... it doesn't work.
    "My brain is just no good at being a relational Database - my relations suck real bad!"

  3. #3
    Join Date
    Mar 2008
    Posts
    89
    Ok, I got it myself actually.

    I picked up another idea and ended up doing it this way:

    Code:
    Selection.AutoFilter Field:=9, Criteria1:="<>NONE"
      Cells.Select
      Range("K9").Activate
      Selection.Font.Bold = True
    Range("I2631").Select
    Selection.AutoFilter Field:=9, Criteria1:="*"
    Thanks for... well providing the crying shoulder.
    "My brain is just no good at being a relational Database - my relations suck real bad!"

  4. #4
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Since this issue appears to be much more appropriate to the Excel forum than it does to VB, I'm moving to the Excel forum...
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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