ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   HELP copy and paste (https://www.excelbanter.com/excel-programming/439175-help-copy-paste.html)

stacia

HELP copy and paste
 
I am trying to copy a range of cells and paste them after every Total
This is what I have so far:

Sub b8pastetitle()

Dim theRange As Range
Dim lastrow&, firstRow&, x&
Set theRange = ActiveSheet.UsedRange
lastrow = theRange.Cells(theRange.Cells.Count).Row
firstRow = theRange.Cells(1).Row
For x = lastrow To firstRow Step -1
If InStr(1, Cells(x, 1), "Total") 0 Then
Range("A5 : G7").Select
Selection.Copy
ActiveSheet.Paste Destination:=Worksheets("Payroll").Cells(x + 2,
1).Selection.Paste

End If
Next
End Sub

--
Stacia

Don Guillett[_2_]

HELP copy and paste
 
Please ONLY post in ONE place. See your other post

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"stacia" wrote in message
...
I am trying to copy a range of cells and paste them after every Total
This is what I have so far:

Sub b8pastetitle()

Dim theRange As Range
Dim lastrow&, firstRow&, x&
Set theRange = ActiveSheet.UsedRange
lastrow = theRange.Cells(theRange.Cells.Count).Row
firstRow = theRange.Cells(1).Row
For x = lastrow To firstRow Step -1
If InStr(1, Cells(x, 1), "Total") 0 Then
Range("A5 : G7").Select
Selection.Copy
ActiveSheet.Paste Destination:=Worksheets("Payroll").Cells(x + 2,
1).Selection.Paste

End If
Next
End Sub

--
Stacia




All times are GMT +1. The time now is 01:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com