josros60

Well-known Member
Joined
Jun 27, 2010
Messages
780
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:

10/19/2018CAD800.0010/19/2018399993000mario
10/19/2018CAD899.0010/19/201873393087887Antonio

<tbody>
</tbody>

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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,214,901
Messages
6,122,157
Members
449,068
Latest member
shiz11713

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