Copy/paste range and fill empty rows

EvertRa

New Member
Joined
Jul 1, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hi, I am trying to write a VBA code, but do not manage to figure out the solution for this.

A RPA tool is running and pasting in data into sheet1. This is always 8 columns, A:H. However, there will only be data in all columns in the first row. For the rest of the rows there will only be data in column A:D. The first part of the code I am trying to write is to copy the data in row 1, col E:H into all rows down to the last row.

Then the process needs to be repeated. It will now be new data in sheet1, and the VBA code needs to copy-paste this into the first free row in sheet 2.

The number of columns is static, but the number of rows in each range is dynamic.

Any good ideas on how to do this?
 

Attachments

  • Example.png
    Example.png
    32.1 KB · Views: 10

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hi EvertRa

I have a macro I use that will do this. it will need you to highlight the columns or add a selection statement
VBA Code:
Sub fillDown()
'fill the gaps in a column with the value from the cell above when a cell is blank

    For Each cell In Selection.cells
        If Len(cell.value) = 0 Then
            cell.value = cell.Offset(-1, 0).value
        End If
    Next

End Sub

All this code does is run through the selected cells one at a time from the top and if the cell is empty copy the cell above.
 
Upvote 0

Forum statistics

Threads
1,215,067
Messages
6,122,949
Members
449,095
Latest member
nmaske

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