PC Review


Reply
Thread Tools Rate Thread

Chnge code help requited

 
 
=?Utf-8?B?QW50aG9ueQ==?=
Guest
Posts: n/a
 
      11th Mar 2007
Hi,
I have been given this code to randomly chose a number from range R36:R57
then copy it to cell E34

Sub getnumber()
x = Int((52 - 32 + 1) * Rnd + 32)
mynumber = Worksheets("sheet1").Cells(x, 18).Value
Worksheets("sheet1").Cells(14, 4).Value = mynumber
End Sub

2 changes to the code are required please
1) when a number is selected from the range and pasted to E14 can it be
removed from the original range?
2) If a blank cell is randomly selected, ignore it and loop until a number
is found.

Hope this can be done and thanks in advance
 
Reply With Quote
 
 
 
 
=?Utf-8?B?R2FyeScncyBTdHVkZW50?=
Guest
Posts: n/a
 
      11th Mar 2007
Sub getnumber()
mynumber = ""
Do While mynumber = ""
x = Int((57 - 32 + 1) * Rnd + 32)
mynumber = Worksheets("sheet1").Cells(x, 18).Value
Worksheets("sheet1").Cells(x, 18).Clear
Worksheets("sheet1").Cells(34, 5).Value = mynumber
Loop
End Sub


will pick a value randmly from R36:R57 then copy it to cell E34
then do the clear and then loop if necessary

--
Gary''s Student
gsnu200710


"Anthony" wrote:

> Hi,
> I have been given this code to randomly chose a number from range R36:R57
> then copy it to cell E34
>
> Sub getnumber()
> x = Int((52 - 32 + 1) * Rnd + 32)
> mynumber = Worksheets("sheet1").Cells(x, 18).Value
> Worksheets("sheet1").Cells(14, 4).Value = mynumber
> End Sub
>
> 2 changes to the code are required please
> 1) when a number is selected from the range and pasted to E14 can it be
> removed from the original range?
> 2) If a blank cell is randomly selected, ignore it and loop until a number
> is found.
>
> Hope this can be done and thanks in advance

 
Reply With Quote
 
=?Utf-8?B?QW50aG9ueQ==?=
Guest
Posts: n/a
 
      11th Mar 2007
thanks for that - just great

"Gary''s Student" wrote:

> Sub getnumber()
> mynumber = ""
> Do While mynumber = ""
> x = Int((57 - 32 + 1) * Rnd + 32)
> mynumber = Worksheets("sheet1").Cells(x, 18).Value
> Worksheets("sheet1").Cells(x, 18).Clear
> Worksheets("sheet1").Cells(34, 5).Value = mynumber
> Loop
> End Sub
>
>
> will pick a value randmly from R36:R57 then copy it to cell E34
> then do the clear and then loop if necessary
>
> --
> Gary''s Student
> gsnu200710
>
>
> "Anthony" wrote:
>
> > Hi,
> > I have been given this code to randomly chose a number from range R36:R57
> > then copy it to cell E34
> >
> > Sub getnumber()
> > x = Int((52 - 32 + 1) * Rnd + 32)
> > mynumber = Worksheets("sheet1").Cells(x, 18).Value
> > Worksheets("sheet1").Cells(14, 4).Value = mynumber
> > End Sub
> >
> > 2 changes to the code are required please
> > 1) when a number is selected from the range and pasted to E14 can it be
> > removed from the original range?
> > 2) If a blank cell is randomly selected, ignore it and loop until a number
> > is found.
> >
> > Hope this can be done and thanks in advance

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
making a chnge in a report Meca Lee Microsoft Access Reports 1 15th Jan 2010 09:04 PM
chnge query for a join file JRough Microsoft Access Database Table Design 1 13th Jun 2008 07:50 PM
chnge loca where .adp creates DB on Sql Server? BF Microsoft Access ADP SQL Server 3 20th Apr 2005 01:06 PM
Chnge IE Default FTP Program Keith Windows XP General 6 30th May 2004 06:17 PM
Chnge the font and language in contacts? =?Utf-8?B?R2Vvcmdl?= Microsoft Outlook Contacts 0 27th Feb 2004 12:01 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:10 AM.