| | Post: 13 | Registrato il: 13/01/2019
| Città: LESMO | Età: 76 | Utente Junior | 2010 | | OFFLINE | |
|
06/04/2020 11:23 | |
Buongiorno a tutti e buon inizio di settimana!
Esiste un metodo più veloce per ottenere i valori di:
Prima riga - Ultima riga - Prima colonna - Ultima colonna
di una SELEZIONE di celle
più semplice di quella che ho impostato qui sotto?
Grazie a tutti per il vostro aiuto.
Sub NumRigheColonne()
Dim Pr, Pc, Ur, Uc, contaR, contaC As Integer
Dim myRange As Range
Set myRange = Selection
Pr = myRange.Row
Ur = 1
Pc = myRange.Column
Uc = 1
For Each cel In myRange
contaR = cel.Row
If contaR > Ur Then Ur = contaR
contaC = cel.Column
If contaC > Uc Then Uc = contaC
Next
MsgBox ("Prima riga = " & Pr & " Ultima riga = " & Ur & " Prima colonna = " & Pc & " Ultima colona = " & Uc)
End Sub |
|
| | Post: 2.635 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
06/04/2020 11:44 | |
ciao
myrange.column = prima colonna
myrange.column+myrange.columns.count-1 = ultima colonna
lo stesso per le righe
saluti
Domenico
Win 10 - Excel 2016 |
| | Post: 13 | Registrato il: 13/01/2019
| Città: LESMO | Età: 76 | Utente Junior | 2010 | | OFFLINE | |
|
06/04/2020 13:55 | |
Grazie Domenico dell'aiuto (tra 72enni!!).
Posso chiederti ancora un aiuto? Nel MsgBox dell'ultima istruzione della macro:
MsgBox ("Prima riga = " & Pr & " Ultima riga = " & Ur & " Prima colonna = " & Pc & " Ultima colona = " & Uc)
é possibile farlo andare a capo in modo che presenti le 4 risposte su righe diverse e non di seguito?
Grazie di tutto,
Alberto
La macro semplificata diventa per chi dovesse averne bisogno:
Sub NumeroRigheColonne ()
Dim Pr, Pc, Ur, Uc As Integer
Dim myRange As Range
Set myRange = Selection
Pr = myRange.Row
Ur = myRange.Row + myRange.Rows.Count - 1
Pc = myRange.Column
Uc = myRange.Column + myRange.Columns.Count - 1
MsgBox ("Prima riga = " & Pr & " Ultima riga = " & Ur & " Prima colonna = " & Pc & " Ultima colona = " & Uc)
End Sub |
| | Post: 2.639 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
06/04/2020 16:29 | |
ciao
MsgBox "Prima riga = " & Pr & _
" Ultima riga = " & Ur & _
" Prima colonna = " & Pc & _
" Ultima colona = " & Uc
saluti
[Modificato da dodo47 06/04/2020 16:30] Domenico
Win 10 - Excel 2016 |
|
06/04/2020 16:45 | |
Forse intendeva... MsgBox "Prima riga = " & Pr & vbCrLf & " Ultima riga = " & Ur & vbCrLf & " Prima colonna = " & Pc & vbCrLf & " Ultima colona = " & Uc |
| | Post: 2.641 | Registrato il: 06/04/2013
| Utente Veteran | 2010 | | OFFLINE |
|
06/04/2020 17:28 | |
eheh...già... che vuoi fare, quando uno è anziano!!
saluti
Domenico
Win 10 - Excel 2016 |
| | Post: 14 | Registrato il: 13/01/2019
| Città: LESMO | Età: 76 | Utente Junior | 2010 | | OFFLINE | |
|
06/04/2020 19:02 | |
Grazie a tutti, un saluto ed un augurio di buona salute.
Alberto |
|
|