Alex Piotto
Board Regular
- Joined
- Jul 5, 2016
- Messages
- 82
- Office Version
- 2007
- Platform
- Windows
Greetings!
I need to make a loop to copy the values of almost 300 rows (from D6 to D300) and 3 columns (A, B, C) from the ActiveSheet into a yesno message box. To give the user a chance, you know...
I really don't know where to start. Never really used loops before...
Here is my code to give you the idea...
The code works... but obviously for 3 rows only...
And I am unable to put the values of the 3 columns together as one because I get a Mismatch error...
I need to make a loop to copy the values of almost 300 rows (from D6 to D300) and 3 columns (A, B, C) from the ActiveSheet into a yesno message box. To give the user a chance, you know...
I really don't know where to start. Never really used loops before...
Here is my code to give you the idea...
VBA Code:
Sub INSERIRE_ENTRATE()
Dim QUA6 As String
Dim UNITAPRO6 As String
QUA6 = ThisWorkbook.Sheets("ENTRATE").Range("D6").Value
UNITAPRO6 = " " + ThisWorkbook.Sheets("ENTRATE").Range("B6").Value + " " + ThisWorkbook.Sheets("ENTRATE").Range("A6").Value
Dim QUA7 As String
Dim UNITAPRO7 As String
QUA7 = ThisWorkbook.Sheets("ENTRATE").Range("D7").Value
UNITAPRO7 = " " + ThisWorkbook.Sheets("ENTRATE").Range("B7").Value + " " + ThisWorkbook.Sheets("ENTRATE").Range("A7").Value
Dim QUA8 As String
Dim UNITAPRO8 As String
QUA8 = ThisWorkbook.Sheets("ENTRATE").Range("D8").Value
UNITAPRO8 = " " + ThisWorkbook.Sheets("ENTRATE").Range("B8").Value + " " + ThisWorkbook.Sheets("ENTRATE").Range("A8").Value
ILTUTTO = QUA6 + UNITAPRO6 + vbNewLine + QUA7 + UNITAPRO7 + vbNewLine + QUA8 + UNITAPRO8 + vbNewLine
'LOOOOOOOOPPPPPPP ?????? HOW? 300 rows down!!!
Dim answer As Integer
answer = MsgBox("TUTTO GIUSTO? SICURO? RICONTROLLA..." + vbNewLine + vbNewLine + ILTUTTO, vbYesNo)
If answer = vbNo Then
Exit Sub
Else
'DO SOME STUFF
ThisWorkbook.Sheets("DETTAGLI-ENTRATE").Protect AllowFiltering:=True
ActiveSheet.EnableSelection = xlNoSelection
Application.CutCopyMode = False
Application.ScreenUpdating = True
End If
End Sub
The code works... but obviously for 3 rows only...
And I am unable to put the values of the 3 columns together as one because I get a Mismatch error...