save sheet to folder

radu_moflea

New Member
Joined
Jan 20, 2010
Messages
1
my code is
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
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,226,694
Messages
6,192,473
Members
453,726
Latest member
JoeH57

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top