Offset after loop

horizonflame

Board Regular
Joined
Sep 27, 2018
Messages
186
Office Version
  1. 2013
Hi All

I would like to copy all non-blank cells in range R5:X7000 into the adjacent cell in Range K5:Q7000 as paste values. Essentially any non-blank cells will paste as a value in same row but 7 columns to the left. I have what I think is a good piece of code but need some help how to edit it to my cell range and paste area.

Code:
Sub CopyData()    Application.ScreenUpdating = False
    Dim c As Range
    For Each c In Range("K5:Q7000")
        If c.Offset(0, 1) <> "" Then     NEED TO CHANGE THIS LINE
            c.Copy
            Cells(Rows.Count, "H").End(xlUp).Offset(1, 0).PasteSpecial (xlPasteValues)   NEED TO CHANGE THIS LINE
            Application.CutCopyMode = False
        End If
    Next c
    Application.ScreenUpdating = False
End Sub

Many thanks
 
Last edited:

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Re: Help with Offset after loop

Great! I am happy I was able to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,961
Members
452,539
Latest member
delvey

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