View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.newusers
JLatham JLatham is offline
external usenet poster
 
Posts: 2,203
Default VBA copy cell to another worksheet

Good to hear that. Glad I could help.

"franco monte" wrote:

Thanks JLatham, now it's work correct! Thanks again!!!!

Private Sub Memorizza_Click()
Dim ObjWorshett As Worksheet
Dim strNomeFile As String
Dim UltimaRiga As Long
Dim Riga As Long

' new variables used
Dim objWorkbook As Workbook
Dim valueFromThisWorkbook As Variant

Application.ScreenUpdating = False ' Lavora in background

valueB2 = ActiveSheet.Range("B2").Value 'Agente
' ....

strNomeFile = "\\srv01\Dp\ANTONELLA\Lista sblocco ordini.xls"

'open the other workbook, do not update links, _
do NOT open as read only
Set objWorkbook = Workbooks.Open(strNomeFile, False, False)
Set ObjWorshett = objWorkbook.Sheets(1)

UltimaRiga = ObjWorshett.Range("A" & Rows.Count).End(xlUp).Row
Riga = UltimaRiga + 1

ObjWorshett.Cells(Riga, 1).Value = valueB2 'Agente
' ....

Set ObjWorshett = Nothing
objWorkbook.Close True ' close and save changes
Set objWorkbook = Nothing
Application.ScreenUpdating = True ' Fine Lavora in background
End Sub
.