Pagina precedente | 1 | Pagina successiva
Vota | Stampa | Notifica email    
Autore

Sorteggio Tot Numeri

Ultimo Aggiornamento: 27/02/2017 20:16
Post: 124
Registrato il: 04/11/2016
Città: SASSARI
Età: 48
Utente Junior
2010
OFFLINE
27/02/2017 17:43

SALVE A TUTTI,

ci sto provando in tutte le maniere , ma purtroppo sono negato.

mi aiutereste a realizzare una macro che mi sorteggi tot numeri da un determinato range?

allego file di esempio
[Modificato da ema.cab 27/02/2017 17:45]
Post: 2.568
Registrato il: 03/04/2013
Utente Veteran
Excel 2000 - 2013
OFFLINE
27/02/2017 20:04

Buona sera, Ema.Cab;
la struttura del Codice VBA è, più o memo, sempre la stessa.
In questo caso, ho definito tre costanti:
- PRg As Byte = 15 ---> Prima riga
- URg As Byte = 31 ---> Ultima riga
- Cln As Byte = 27 ---> Colonna nella quale sono inseriti i Valori

Option Explicit

Sub Random_n()
Application.ScreenUpdating = False
Const PRg As Byte = 15
Const URg As Byte = 31
Const Cln As Byte = 27
Dim lNum As Byte, r As Byte, n As Byte, NVis As Byte
Dim nxx As Integer
Dim arNum() As Byte
Dim j As Integer

    Range(Cells(PRg, Cln + 2), Cells(URg, Cln + 2)).ClearContents
        lNum = URg - PRg + 1
            NVis = Cells(15, 34).Value
ReDim arNum(1 To lNum)
            For j = 1 To lNum
                arNum(j) = Cells(j + PRg - 1, Cln).Value
            Next j
        nxx = 1
    For j = lNum To 1 Step -1
        r = Int((j * Rnd) + 1)
        n = arNum(r)
        arNum(r) = arNum(j)
        arNum(j) = n
        Cells(nxx + PRg - 1, Cln + 2) = arNum(j)
            nxx = nxx + 1
                If nxx > NVis Then Exit For
    Next j
        Erase arNum
Application.ScreenUpdating = True
End Sub



A disposizione.

Buona serata.

Giuseppe

Windows XP - Excel 2000
Windows 10 - Excel 2013
Post: 124
Registrato il: 04/11/2016
Città: SASSARI
Età: 48
Utente Junior
2010
OFFLINE
27/02/2017 20:16

fantastico GiuseppeMN

sei un grande

grazie mille di cuore


http://www.erismag.it/Servizio/ForumExcel/Smiles/Faccina_0008.gif
Vota:
Amministra Discussione: | Chiudi | Sposta | Cancella | Modifica | Notifica email Pagina precedente | 1 | Pagina successiva
Nuova Discussione
 | 
Rispondi
Cerca nel forum
Tag discussione
Discussioni Simili   [vedi tutte]
Feed | Forum | Bacheca | Album | Utenti | Cerca | Login | Registrati | Amministra
Tutti gli orari sono GMT+01:00. Adesso sono le 05:40. Versione: Stampabile | Mobile | Regolamento | Privacy
FreeForumZone [v.6.1] - Copyright © 2000-2024 FFZ srl - www.freeforumzone.com