dinuovo a chiedere il vostro aiuto
dunque
ho creato un userform per l'aggiunta di date di controllo su una tabella funziona tutto tranne che quando và a copiare i dati che inserisco me li copia in un formato tutto suo e cosa ancora più spiacevole fà saltare le formule (gentilmente raggiunte con l'aiuto di Anthony47 )e le formattazioni della tabella nella quale vado a copiare i dati.Vi riporto il mio codice il problema che vorrei risolvere è :
-formattazione da utilizzare : quella della tabella di destinazione
-formattazione date in gg mm aaaa ma credo che questa si risolva in automatico se riesco a soddisfare la prima domanda
Vi ringrazio per l'aiuto
(scusate il casino e il disordine sono ancora pivello )
Option Explicit
Dim sh As Worksheet
Private Sub CommandButton2_Click()
Dim lRisposta As Long
Dim lRiga As Long
Dim lng As Long
lRisposta = MsgBox(Prompt:="Modificare il contenuto delle celle.", _
Title:="Attenzione", _
Buttons:=vbYesNo + vbQuestion)
With sh
If lRisposta = vbYes Then
lRiga = .Range("B" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
If CStr(.Cells(lng, 2).Value) = Me.ComboBox1.Text Then
.Cells(lng, 17).Value = Me.TextBox3.Text
.Cells(lng, 18).Value = Me.TextBox4.Text
Exit For
End If
Next
End If
End With
End Sub
Private Sub CommandButton3_Click()
Dim lRisposta As Long
Dim lRiga As Long
Dim lng As Long
lRisposta = MsgBox(Prompt:="Modificare il contenuto delle celle.", _
Title:="Attenzione", _
Buttons:=vbYesNo + vbQuestion)
With sh
If lRisposta = vbYes Then
lRiga = .Range("B" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
If CStr(.Cells(lng, 2).Value) = Me.ComboBox1.Text Then
.Cells(lng, 19).Value = Me.TextBox5.Text
.Cells(lng, 20).Value = Me.TextBox6.Text
Exit For
End If
Next
End If
End With
End Sub
Private Sub CommandButton4_Click()
Dim lRisposta As Long
Dim lRiga As Long
Dim lng As Long
lRisposta = MsgBox(Prompt:="Modificare il contenuto delle celle.", _
Title:="Attenzione", _
Buttons:=vbYesNo + vbQuestion)
With sh
If lRisposta = vbYes Then
lRiga = .Range("B" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
If CStr(.Cells(lng, 2).Value) = Me.ComboBox1.Text Then
.Cells(lng, 21).Value = Me.TextBox7.Text
.Cells(lng, 22).Value = Me.TextBox8.Text
Exit For
End If
Next
End If
End With
End Sub
Private Sub Label4_Click()
End Sub
Private Sub TextBox5_Change()
End Sub
Private Sub UserForm_Initialize()
Set sh = ThisWorkbook.Worksheets("Scadenze")
Call mCaricaComboBox
End Sub
Private Sub mCaricaComboBox()
Dim lRiga As Long
Dim lng As Long
With sh
lRiga = .Range("B" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
Me.ComboBox1.AddItem (.Cells(lng, 2).Value)
Next
End With
End Sub
Private Sub ComboBox1_Click()
Dim lRiga As Long
Dim lng As Long
With sh
lRiga = .Range("B" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
If CStr(.Cells(lng, 2).Value) = Me.ComboBox1.Text Then
Me.TextBox1.Text = .Cells(lng, 15).Value
Me.TextBox2.Text = .Cells(lng, 16).Value
Me.TextBox3.Text = .Cells(lng, 17).Value
Me.TextBox4.Text = .Cells(lng, 18).Value
Me.TextBox5.Text = .Cells(lng, 19).Value
Me.TextBox6.Text = .Cells(lng, 20).Value
Me.TextBox7.Text = .Cells(lng, 21).Value
Me.TextBox8.Text = .Cells(lng, 22).Value
Exit For
End If
Next
End With
End Sub
Private Sub CommandButton1_Click()
Dim lRisposta As Long
Dim lRiga As Long
Dim lng As Long
lRisposta = MsgBox(Prompt:="Modificare il contenuto delle celle.", _
Title:="Attenzione", _
Buttons:=vbYesNo + vbQuestion)
With sh
If lRisposta = vbYes Then
lRiga = .Range("B" & .Rows.Count).End(xlUp).Row
For lng = 2 To lRiga
If CStr(.Cells(lng, 2).Value) = Me.ComboBox1.Text Then
.Cells(lng, 15).Value = Me.TextBox1.Text
.Cells(lng, 16).Value = Me.TextBox2.Text
Exit For
End If
Next
End If
End With
End Sub
Private Sub UserForm_Terminate()
Set sh = Nothing
End Sub