LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Increase your Karma Points -Help a newbie out

Hi,

I'm a hardware guy by trade so VB is very new to me (i.e. first time use
was yesterday). Anyway I have the following in a cell in Excel (Excel
2000 SP-3):

=INDEX(Sheet2!A1:A102,RANDBETWEEN(1,COUNTA(Sheet2! A1:A102)),1)

I have a list of words in the first column of sheet 2 and it grabs one
of the words at random. It works perfectly.

I have a 4x4 matrix that I'm randomly populating, so I have that
function in all 16 cells, but as you can imagine I sometimes get
duplicates. I don't want that so I cracked open VB (Visual Basic 6.0)
and I did the following:

'*****************CodeStart****************
Sub RandomWord()
'copy my list to the second column (this part is working)
Range("A1:A102").Copy Destination:=Range("B1:B102")

'cut one cell out randomly and place into C1 (Not Working)
Range(Application.WorksheetFunction.Index("B1:B102 ",
Application.WorksheetFunction.RANDBETWEEN(1,
Application.WorksheetFunction.CountA("B1:B102")), 2)).Cut
Destination:=Range("C1")

'call function to delete any empty cells in a row (this part is working)
Call del_empty_cell()

End Sub
'*****************CodeEnd****************

When I run the code I get the following error:
Runtime Error: 1004
"unable to get the Index property of WorksheetFunction class"

What confuses me is it seems that index (or perhaps CountA) is not
getting a valid value but I don't see how that can be so, because the
copy worked. Your help is appreciated.

-Jim Wick
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Format numbers from percentage points to basis points Robaroo Excel Discussion (Misc queries) 2 April 3rd 23 06:58 PM
Number in cell increase with increase in font size. Value increases with increase in font.[_2_] Excel Discussion (Misc queries) 2 August 9th 07 01:58 PM
Real Newbie newbie question Dave New Users to Excel 0 January 10th 07 07:55 PM
How do I find points on a curve between known points? Cybertori Excel Worksheet Functions 1 August 30th 06 07:57 PM
Newbie to charts question - projecting values between data points 38N90W Excel Discussion (Misc queries) 3 January 6th 05 05:15 AM


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"