Copy range value, format and formulas

Apple08

Active Member
Joined
Nov 1, 2014
Messages
450
Hi All

I want to copy and paste a range's value, format and formulas, I have a macro below and please could you let me know how to edit it to make all of the values/format/formulas be included? Thanks.

VBA Code:
Private Sub Copy()

Dim Last_Row As Long
Sheets("Master").Select
Last_Row = Range("A" & Rows.Count).End(xlUp).Row

   
Dim LR As Long
    LR = Sheets("Copy").Range("A" & Rows.Count).End(xlUp).Row
    
    Sheets("Copy").Range("A2:AC" & LR).Copy
    Sheets("Master").Range("A" & Last_Row + 1).PasteSpecial


End Sub
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
How about
VBA Code:
    Sheets("Copy").Range("A2:AC" & LR).Copy    Sheets("Master").Range("A" & Last_Row + 1)
 
Upvote 0
Solution
You're welcome & thanks for the feedback.
 
Upvote 0
Hi Fluff

I have another macro below and please could you help to edit it to paste in all values/format/formulas? Many thanks.

VBA Code:
Sub I_PasteData_Master()

Dim Del As Variant
Del = Array("STEM", "FASS", "WELS", "PVC-S", "FBL") ' Modify Sheet names if needed
Dim lastrow As Long
Dim ans As Long
ans = UBound(Del)
Dim c As Long
Dim counter As Long
counter = 0
c = "1" ' Column Number Modify this to your need
lastrow = Cells(Rows.Count, c).End(xlUp).Row

On Error Resume Next
    Sheets("SUP Tracker").ShowAllData
  On Error GoTo 0

With Sheets("SUP Tracker").Cells(1, c).Resize(lastrow)

For i = 0 To ans
    .AutoFilter 1, Del(i), Operator:=xlFilterValues
    counter = .Columns(c).SpecialCells(xlCellTypeVisible).Count
    If counter > 1 Then .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible).EntireRow.Copy Sheets(Del(i)).Cells(2, 1)
counter = 0
Next
.AutoFilter
End With
End Sub
 
Upvote 0
Try
VBA Code:
With Sheets("SUP Tracker")
For i = 0 To ans
    .Cells(1, C).Resize(LastRow).AutoFilter 1, Del(i), Operator:=xlFilterValues
    counter = .Columns(C).SpecialCells(xlCellTypeVisible).Count
    If counter > 1 Then .AutoFilter.Range.Offset(1).Resize(LastRow - 1).EntireRow.Copy Sheets(Del(i)).Cells(2, 1)
counter = 0
Next
.AutoFilter
End With
 
Upvote 0
Thanks Fluff, however the macro stopped at .AutoFilter while running in the middle, please could you help.

i wonder it could be something to do with this:

VBA Code:
On Error Resume Next
    Sheets("SUP Tracker").ShowAllData
  On Error GoTo 0
 
Upvote 0
What is the error message & number & what line is highlighted?
 
Upvote 0
Run-time error '438'
Object doesn't support this property or method

.AutoFilter is highlighted
 
Upvote 0
Try changing it to
VBA Code:
.AutoFilterMode = False
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,659
Members
449,114
Latest member
aides

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