Copy cell range if cell has data paste offset

Capt_Antihero

New Member
Joined
Jun 16, 2014
Messages
14
Hello,

I have a spreadsheet with data that sometimes every 20th row is misaligned. The sheet will be of varying row lengths depending on the data so I have nothing set. What I need is a macro in VBA that will find the first cell in A1 of Sheet1 with data and if there is data in that cell (lets say the first cell it finds is A20) then to select 9 cells including A20 (A20:J20) and copy and paste the data as an offset 2 cells to the right (it will end up being column C)

Once this is done I would need the macro to keep looping through column A until it finds every cell with data as above and completes the copy and paste offset so I need it to loop until there is no data in column A. Can any excel expert help me with this seemingly simple macro?
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
If I understand your query, this may do that.

Copy to the sheet module.

Regards,
Howard


Code:
Option Explicit

Sub Cut_Off()

Dim c As Range
Dim Lrow As Long
Dim aRng As Range
Lrow = Cells(Rows.Count, "A").End(xlUp).Row
Set aRng = Range("A1:A" & Lrow)

For Each c In aRng
  If c <> "" Then
    c.Resize(1, 10).Cut c.Offset(, 2)
  End If
Next

End Sub
 
Upvote 0

Forum statistics

Threads
1,223,268
Messages
6,171,100
Members
452,379
Latest member
IainTru

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