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: 19
Default choose range based on criteria

Hello,

I am trying to create a macro that would choose a random name based on the
first letter of that name if cell I8 has a letter in it. (e.g. if I8 has A
in it, the random name generator would only randomly choose from the names
starting with A). I have the random part working (I have cells 1 to 1238
chosen for the input) but do not know how to add in the criteria if a
specific letter is chosen from I8.

Here is the code I was working on:

Sub RandomLots()



Dim rndnum As Integer
Dim up As Integer
Dim low As Integer
Dim outp As String
Dim st As String

If Cells(8, 6) < "ANY" Then st = Cells(8, 6).Value = ""
Else
Cells(8, 6).Value = ""


Range("StartW").AdvancedFilter _
Action:=xlFilterInPlace, _
CriteriaRange:=Range("Criteria")
Else

Randomize

rndnum = Int((1238 - 1 + 1) * Rnd + 1)
Sheets("Lots").Range("A" & rndnum).Copy Destination:=Sheets("Lots").Cells(3,
9)

End Sub

Thanks,

Ivan
 
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
Summing a range of cells based on criteria in another range Jack Excel Worksheet Functions 2 November 5th 09 01:46 AM
choose a range to copy paste based on data in the cells aileen Excel Programming 2 October 6th 08 07:12 PM
Copying Range Based On Certain Criteria? Possible looping through the Range Big H Excel Programming 1 October 27th 06 03:32 AM
MIN within range based on criteria StevenL Excel Discussion (Misc queries) 9 July 11th 05 11:33 PM
group rows in a range based on criteria from another range (vba) Andy Excel Programming 2 April 28th 04 03:26 AM


All times are GMT +1. The time now is 09:29 PM.

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

About Us

"It's about Microsoft Excel"