Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Carlton Martinez   on Jan 21 In MS Office Category.

  
Question Answered By: Roosevelt Jenkins   on Jan 21

I've got the code  working fairly well, but for
some reason it sometimes highlights the blank cell  after the last cell
containing data. For example, StartRow is 2, and cells  A2:A5 have data in them,
but sometimes cell A6 is highlighted. Any idea what I've done wrong? My code
is as follows:

****************************************************************
Sub HighlightRandomCell()
Columns(1).Interior.ColorIndex = 0
StartRow = 2RowCnt = Application.WorksheetFunction.CountA(Range("A" & StartRow &
":A65000"))
randrow = Int((RowCnt + 1) * Rnd) + StartRow
Cells(randrow, 1).SelectCells(randrow, 1).Interior.ColorIndex = 6
End Sub
****************************************************************

Share: 

 

This Question has 2 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Select random cell in list and highlight contents Or get search suggestion and latest updates.


Tagged: