I want to copy a range of cells on a sheet to another sheet as a summary.
Ihave a spreadsheet, with on one sheet columns a5:k20
Column a name.
b: sometext
column c:k are numbers, and those cells have a conditional format.
I want to copy the cells a5;k20 to another summary sheet.
The vba code i found is copying ths but it dosn't take always the right conditional format with it.
Sub Copy_E1_Rekenen()
Dim SourceRange As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'fill in the Source Sheet and range
Set SourceRange = Sheets("E1-Rekenen").Range("A5:K20")
'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("DatabaseE1R")
Lr = lastrow(DestSheet)
'With the information from the LastRow function we can
'create a destination cell and copy/paste the source range
Set DestRange = DestSheet.Range("A" & Lr + 1)
SourceRange.Copy DestRange
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
Does anybody have a solution.
vergelijken = E1-Rekenen
Verg = DatabaseE1R
Guido
Attachment | Size |
---|---|
Vergelijken.xlsx | 11.85 KB |
Verg..xlsx | 8.79 KB |
Try this
Hi Try this hope this will help you..
Sub Copy_E1_Rekenen()
Dim wkb As Workbook, wkb2 As Workbook
Dim rng As Range
Dim lastrow As Long
Set wkb = ThisWorkbook
Set wkb2 = Workbooks("Verg.")
Set rng = wkb.Sheets(1).Range("a5:k20")
lastrow = wkb2.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row
rng.Copy Destination:=wkb2.Sheets(1).Range("A" & lastrow + 1)
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub