Results 1 to 4 of 4

Thread: Excel and Macros

  1. #1

    Thread Starter
    Hyperactive Member boku's Avatar
    Join Date
    Dec 2004
    Posts
    386

    Unhappy Excel and Macros

    Im trying to use:

    VB Code:
    1. Sub highlite()
    2.  
    3.     If Range("V" & Int(Rnd * "10000")).Select Then
    4.     Rows(Int(Rnd * "10000") & ":" & Int(Rnd * "10000")).Select
    5.     Range("F" & Int(Rnd * "10000")).Activate
    6.     With Selection.Interior
    7.         .ColorIndex = 39
    8.         .Pattern = xlSolid
    9.     End With
    10.     End If
    11.    
    12. End Sub

    in excel, to highlight a whole row, if i click on a cell in that row, then if I click on another row, it de-highlits back to how it was originally and highlights the new row! what am I ding wrong and is there a solution?
    -BoKu-

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Excel and Macros

    Excel VBA question moved to Office Development

  3. #3
    Member
    Join Date
    Aug 2005
    Location
    West Midlands, UK
    Posts
    33

    Re: Excel and Macros

    Try this:
    VB Code:
    1. Sub Highlite
    2.   ActiveCell.EntireRow.Select
    3.   With Selection.Interior
    4.      .ColorIndex = 39
    5.      .Pattern = xlSolid
    6.   End With
    7. End sub
    If you are trying to highlight rows that are in a certian range (eg rows 15-30)only then try:
    VB Code:
    1. Sub Highlite
    2.   If ActiveCell.Row > 15 And ActiveCell.Row < 30 Then
    3.     ActiveCell.EntireRow.Select
    4.     With Selection.Interior
    5.        .ColorIndex = 39
    6.        .Pattern = xlSolid
    7.     End With
    8.   End If
    9. End sub
    Hope this helps. If not please advise further and I will try again.
    Last edited by Borg2of6; Feb 7th, 2006 at 10:10 AM.

  4. #4

    Thread Starter
    Hyperactive Member boku's Avatar
    Join Date
    Dec 2004
    Posts
    386

    Re: Excel and Macros

    That worked fine thanks, i can work it myself from there
    -BoKu-

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