radu_moflea
New Member
- Joined
- Jan 20, 2010
- Messages
- 1
my code is
Sunt incepator in vb.
Eu vreau sa pot copia numai anumite celule din sheet "balanta" in folder "balanta", regula de copiere este rand cu rand, adica gaseste urmatorul rand gol din folder balanta si completeza ,pur si simplu mam blocat nu mai stiu ( dar promit sa mai invat).
Va rog sa ma ajutati.
Multumesc
Code:
Sub Salveaza_nir()
On Error GoTo err
Dim Nume As String
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B24").Value, _
Sheets("nir").Range("C24").Value, _
Sheets("nir").Range("D24").Value, _
Sheets("nir").Range("E24").Value, _
Sheets("nir").Range("F24").Value, _
Sheets("nir").Range("G24").Value, _
Sheets("nir").Range("H24").Value, _
Sheets("nir").Range("I24").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B25").Value, _
Sheets("nir").Range("C25").Value, _
Sheets("nir").Range("D25").Value, _
Sheets("nir").Range("E25").Value, _
Sheets("nir").Range("F25").Value, _
Sheets("nir").Range("G25").Value, _
Sheets("nir").Range("H25").Value, _
Sheets("nir").Range("I25").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B26").Value, _
Sheets("nir").Range("C26").Value, _
Sheets("nir").Range("D26").Value, _
Sheets("nir").Range("E26").Value, _
Sheets("nir").Range("F26").Value, _
Sheets("nir").Range("G26").Value, _
Sheets("nir").Range("H26").Value, _
Sheets("nir").Range("I26").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B27").Value, _
Sheets("nir").Range("C27").Value, _
Sheets("nir").Range("D27").Value, _
Sheets("nir").Range("E27").Value, _
Sheets("nir").Range("F27").Value, _
Sheets("nir").Range("G27").Value, _
Sheets("nir").Range("H27").Value, _
Sheets("nir").Range("I27").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B28").Value, _
Sheets("nir").Range("C28").Value, _
Sheets("nir").Range("D28").Value, _
Sheets("nir").Range("E28").Value, _
Sheets("nir").Range("F28").Value, _
Sheets("nir").Range("G28").Value, _
Sheets("nir").Range("H28").Value, _
Sheets("nir").Range("I28").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B29").Value, _
Sheets("nir").Range("C29").Value, _
Sheets("nir").Range("D29").Value, _
Sheets("nir").Range("E29").Value, _
Sheets("nir").Range("F29").Value, _
Sheets("nir").Range("G29").Value, _
Sheets("nir").Range("H29").Value, _
Sheets("nir").Range("I29").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B30").Value, _
Sheets("nir").Range("C30").Value, _
Sheets("nir").Range("D30").Value, _
Sheets("nir").Range("E30").Value, _
Sheets("nir").Range("F30").Value, _
Sheets("nir").Range("G30").Value, _
Sheets("nir").Range("H30").Value, _
Sheets("nir").Range("I30").Value)
NextRow = Sheets("balanta").Range("A65536").End(xlUp).Row + 1
Sheets("balanta").Cells(NextRow, 1).Resize(1, 8).Value = Array( _
Sheets("nir").Range("B31").Value, _
Sheets("nir").Range("C31").Value, _
Sheets("nir").Range("D31").Value, _
Sheets("nir").Range("E31").Value, _
Sheets("nir").Range("F31").Value, _
Sheets("nir").Range("G31").Value, _
Sheets("nir").Range("H31").Value, _
Sheets("nir").Range("I31").Value)
With Application
.DisplayAlerts = False
.ScreenUpdating = False
End With
'stabilim numele noului registru si apoi il salvam cu noul nume
nr_nir = Str(ThisWorkbook.Sheets("nir").Range("F8").Value) + "," + ThisWorkbook.Sheets("nir").Range("C20").Value
ThisWorkbook.Sheets("nir").Copy
ActiveWorkbook.SaveAs "D:\desctop\proiect radu\attachments_2010_01_15\NIR\" + nr_nir + ".xls"
ActiveWorkbook.Close
'deschide registrul initial
Workbooks.Open Filename:= _
"D:\desctop\proiect radu\attachments_2010_01_15\nir test.xls"
'activeaza registrul salvat si apoi il inchide
Windows("D:\desctop\proiect radu\attachments_2010_01_15\NIR\" + nr_nir + ".xls").Activate
ActiveWindow.Close
'activam alertele
Application.DisplayAlerts = True
'ne anunta ca fisierul s-a salvat fara probleme
MsgBox "Fisierul a fost salvat cu succes.", vbOKOnly + vbInformation, "Salvare Fisier"
Exit Sub
err:
MsgBox err.Description, vbOKOnly + vbInformation, "Eroare"
End With
End Sub
Sunt incepator in vb.
Eu vreau sa pot copia numai anumite celule din sheet "balanta" in folder "balanta", regula de copiere este rand cu rand, adica gaseste urmatorul rand gol din folder balanta si completeza ,pur si simplu mam blocat nu mai stiu ( dar promit sa mai invat).
Va rog sa ma ajutati.
Multumesc