copy sheet

josros60

Well-known Member
Joined
Jun 27, 2010
Messages
786
Office Version
  1. 365
Hi,

I have spreadsheet that want to copy another sheet and the date field has formula to copy date from above cell(s) the code copy sheet want to copy sheet with the headings and values to sheet1 but i having this issues

1. is not copy the headings just the records and start in row 2 and row 1 is blank where it should be the headings
2. date is copy formula instead of date values

here is what looks like my payment sheet and what's copying right now:

[TABLE="width: 891"]
<tbody>[TR]
[TD="align: right"]10/19/2018[/TD]
[TD]CAD[/TD]
[TD="align: right"]800.00[/TD]
[TD="align: right"]10/19/2018[/TD]
[TD]3[/TD]
[TD]9999[/TD]
[TD]3000[/TD]
[TD]mario[/TD]
[TD][/TD]
[/TR]
[TR]
[TD="align: right"]10/19/2018[/TD]
[TD]CAD[/TD]
[TD="align: right"]899.00[/TD]
[TD="align: right"]10/19/2018[/TD]
[TD]7[/TD]
[TD]339[/TD]
[TD]3087887[/TD]
[TD]Antonio[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

code here:

Code:
Private Sub CommandButton1_Click()a = Worksheets("Payments").Cells(Rows.Count, 1).End(xlUp).Row


For i = 2 To a


        If Worksheets("Payments").Cells(i, 3).Value > "0" Then


        Worksheets("Payments").Rows(i).Copy
        
        Worksheets("Sheet1").Activate


        b = Worksheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row


       Worksheets("Sheet1").Cells(b + 1, 1).Select


        ActiveSheet.Paste


        Worksheets("Payments").Activate


End If




Next


Application.CutCopyMode = False


ThisWorkbook.Worksheets("Payments").Cells(1, 1).Select


End Sub


thank you,
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
How about
Code:
Private Sub CommandButton1_Click()
   Dim Lr As Long
   
   With Worksheets("Payments")
      Lr = .Cells(Rows.Count, 1).End(xlUp).Row
      If .AutoFilterMode Then .AutoFilterMode = False
      .Range("A1:H1").AutoFilter 3, ">0"
      .Range("A1:A" & Lr).SpecialCells(xlVisible).EntireRow.Copy
      Sheets("Sheet1").Range("A1").PasteSpecial xlPasteValues
      .AutoFilterMode = False
   End With
   Application.CutCopyMode = False
End Sub
 
Upvote 0
Thank you for the quick response.

the only issues are:

doesn't not copy same format like table heading fill color and table column/rows borders and and the date just pasting serial numbers and the others rows values are formatting as General but should be text because when i upload to the bank will give me an error if is not text.

in other words can it copy and paste same format?

thanks again.
 
Upvote 0
Ok, try
Code:
Private Sub CommandButton1_Click()
   Dim Lr As Long
   
   With Worksheets("Payments")
      Lr = .Cells(Rows.Count, 1).End(xlUp).Row
      If .AutoFilterMode Then .AutoFilterMode = False
      .Range("A1:H1").AutoFilter 3, ">0"
      .Range("A1:A" & Lr).SpecialCells(xlVisible).EntireRow.Copy
      Sheets("Sheet1").Range("A1").PasteSpecial xlPasteValues
      Sheets("Sheet1").Range("A1").PasteSpecial xlPasteFormats
      .AutoFilterMode = False
   End With
   Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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