VBA Creating an report on another tab

steelguy

New Member
Joined
Feb 15, 2021
Messages
3
Hi,
i ve got summary in the first image and want to transfer it as Value to another tab to keep records on.
1.First thing i dont know how to transfer values instead of copy cells.
2. Don`t know how to put "current date and time". Date and time should reflect time once button were pressed.
3. As well need to fill which user saved that report.

So at the end i should be like pressing button and saving as values all data on diff tab with keeping all previous savings.

i hope i could explain well.
Excel Vba help 1.JPG
Excel vba help 2.JPG

Excel vba help 3code.JPG
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
VBA Code:
Sub TransferData()

Dim iLastRow As Long

  With Sheets("2 History")
  
    iLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
    
     'User
     
   Range("C1").Copy .Cells(iLastRow, 2)    'Date
   
     'time
     
     Range("C2").Copy .Cells(iLastRow, 4)    'Job Ref
     Range("C3").Copy .Cells(iLastRow, 5)    'Adress
     Range("G2").Copy .Cells(iLastRow, 6)    'Total Weight
     Range("H2").Copy .Cells(iLastRow, 7)    'Steel Cost
     Range("I2").Copy .Cells(iLastRow, 8)    'Galvanise
     Range("K2").Copy .Cells(iLastRow, 9)    'Fabrication
     Range("J2").Copy .Cells(iLastRow, 10)    'Delivery
     Range("L2").Copy .Cells(iLastRow, 11)   'Summary
     
    MsgBox ("Order saved in History tab")
    
  End With
End Sub
 
Upvote 0
Thanks for that, how about
VBA Code:
Sub TransferData()

Dim iLastRow As Long

  With Sheets("2 History")
  
    iLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
    
     
     .Cells(iLastRow, 1).Value = Environ("Username")       'User
     .Cells(iLastRow, 2).Value = Range("C1").Value    'Date
     .Cells(iLastRow, 3).Value = Time       'time
     
     
     .Cells(iLastRow, 4).Value = Range("C2").Value   'Job Ref
     .Cells(iLastRow, 5).Value Range("C3").Value     'Adress
     .Cells(iLastRow, 6).Value = Range("G2").Value   'Total Weight
     .Cells(iLastRow, 7).Value = Range("H2").Value    'Steel Cost
     Range("I2").Copy .Cells(iLastRow, 8)    'Galvanise
     Range("K2").Copy .Cells(iLastRow, 9)    'Fabrication
     Range("J2").Copy .Cells(iLastRow, 10)    'Delivery
     Range("L2").Copy .Cells(iLastRow, 11)   'Summary
     
    MsgBox ("Order saved in History tab")
    
  End With
End Sub
You just need to change the last 4 rows as shown above.
 
Upvote 0
Solution
Thanks for that, how about
VBA Code:
Sub TransferData()

Dim iLastRow As Long

  With Sheets("2 History")
 
    iLastRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
   
    
     .Cells(iLastRow, 1).Value = Environ("Username")       'User
     .Cells(iLastRow, 2).Value = Range("C1").Value    'Date
     .Cells(iLastRow, 3).Value = Time       'time
    
    
     .Cells(iLastRow, 4).Value = Range("C2").Value   'Job Ref
     .Cells(iLastRow, 5).Value Range("C3").Value     'Adress
     .Cells(iLastRow, 6).Value = Range("G2").Value   'Total Weight
     .Cells(iLastRow, 7).Value = Range("H2").Value    'Steel Cost
     Range("I2").Copy .Cells(iLastRow, 8)    'Galvanise
     Range("K2").Copy .Cells(iLastRow, 9)    'Fabrication
     Range("J2").Copy .Cells(iLastRow, 10)    'Delivery
     Range("L2").Copy .Cells(iLastRow, 11)   'Summary
    
    MsgBox ("Order saved in History tab")
   
  End With
End Sub
You just need to change the last 4 rows as shown above.
Perfect, Thank you vm!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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