Dim sh2 As Worksheet: Set sh2 = Worksheets("DataBase")
Dim sh1 As Worksheet: Set sh1 = Worksheets("Scheda")
Dim X, Y, M, N As String
Dim nriga As Long
M = sh1.Cells(9, 2).Value
N = Mid(M, 1, 2) & Mid(M, 4, 2) & Mid(M, 7, 4)
sh2.Activate
sh2.Cells(65000, 1).End(xlUp).Offset(1, 0).Select
ActiveCell.Offset(0, 0).Value = sh1.Cells(9, 6).Value
ActiveCell.Offset(0, 1).Value = sh1.Cells(9, 8).Value
ActiveCell.Offset(0, 2).Value = sh1.Cells(9, 2).Value
ActiveCell.Offset(0, 3).Value = N
X = sh1.Cells(9, 6).Value
Y = N
sh1.Select
sh1.Copy
On Error Resume Next
ActiveWorkbook.SaveAs Filename:= _
"C:Schede2016" & X & "" & Y & ".xlsm", FileFormat:= _
xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
secondo codice
Private Sub CommandButton2_Click()
Dim sh1 As Worksheet: Set sh1 = Worksheets("Scheda")
Dim sh2 As Worksheet: Set sh2 = Worksheets("DataBase")
Dim numrec As Long
Dim alfa As Range
sh2.Range("A2") = UserForm4.TextBox2.Text
sh2.Range("B2") = UserForm4.ComboBox10.Text
sh2.Range("C2") = UserForm4.TextBox3.Text
numrec = sh2.Range("A1").End(xlDown).Row
sh2.Range("A1:D" & numrec).AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=sh2.Range("A1:D2"), CopyToRange:=sh2.Range("G1:J1"), Unique:=False
sh2.Activate
sh2.Range("G3").Select
UserForm3.TextBox2 = ActiveCell.Value
UserForm3.TextBox3 = ActiveCell.Offset(0, 1).Value
UserForm3.TextBox4 = ActiveCell.Offset(0, 2).Value
UserForm3.TextBox5 = ActiveCell.Offset(0, 3).Value
UserForm3.Show
End Sub
terzo codice
Private Sub CommandButton1_Click()
Dim F, R As String
F = UserForm3.TextBox2.Text
R = UserForm3.TextBox5.Text
Workbooks.Open Filename:="C:Schede2016" & F & "" & R & ".xlsm", _
UpdateLinks:=0
End Sub
4 codice
Private Sub CommandButton3_Click()
Dim sh2 As Worksheet: Set sh2 = Worksheets("DataBase")
Dim sh1 As Worksheet: Set sh1 = Worksheets("Scheda")
Dim S As Long
sh2.Range("$A$2:$D$2") = ""
S = sh2.Range("G1").End(xlDown).Row
sh2.Range("G1:J" & S) = ""
UserForm4.ComboBox1 = ""
UserForm4.ComboBox2 = ""
UserForm4.ComboBox3 = ""
UserForm4.ComboBox4 = ""
UserForm4.ComboBox5 = ""
UserForm4.ComboBox6 = ""
UserForm4.ComboBox7 = ""
UserForm4.ComboBox8 = ""
UserForm4.ComboBox9 = ""
UserForm4.ComboBox10 = ""
UserForm4.TextBox2 = ""
UserForm4.TextBox3 = ""
sh1.Activate
sh1.Range("A1").Select
Unload Me
End Sub
|