Help with a macro please

Buns1976

Board Regular
Joined
Feb 11, 2019
Messages
194
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone,

I have a workbook with Sheet 1 in it. Each day Sheet 1 is updated with up to 600 rows of data. We have several rows that we need to copy data to for example, where Cells A3, A4, B3 & B4 below are empty I would like to copy A2 & B2 and so forth down column A & B. I'm trying to come up with a macro to do that if someone could be so kind.

Thank you!!

Column A Column B C D E F
Row1-00000000010054/00020 OZ FOUNTIAN$1.1945$5.95
Row2-00000000010078/00032 OZ FOUNTIAN$1.392121$29.19
Row3-$1.1911$1.19
Row4-22$30.38
Row5-00000000010511/000Refill Fntn$0.791111$8.69
Row6-00000000010528/00044 OZ FOUNTIAN$1.2933$3.87
Row7-$1.491721$31.29
Row8-24$35.16
00000000011037/00016oz Coffee$1.3944$5.56

<tbody>
</tbody>
 
Last edited:

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
So does A2:B2 go in rows 7 & 8 as well ??
The prices in C are different !
 
Upvote 0
Hi there,

A6 & B6 would go in A7, A8, B7 & B8!

Thank you!
 
Upvote 0
Maybe this then
Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To lr
    If Cells(r, 1).Value = "" Then
        Range(Cells(r - 1, 1), Cells(r - 1, 2)).Copy Cells(r, 1)
    End If
Next r
End Sub
 
Upvote 0
Michael,
I messed up! This works great in my test sheet where the first column is "A" however in the actual sheet the first column is "D".
I tried changing the macro to the following but that doesn't seem to work?

Thanks!

Code:
 Sub Merge()Dim lr As Long, r As Long
lr = Cells(Rows.Count, "D").End(xlUp).Row
For r = 2 To lr
    If Cells(r, 1).Value = "" Then
        Range(Cells(r - 1, 1), Cells(r - 1, 2)).Copy Cells(r, 1)
    End If
Next r
End Sub
 
Upvote 0
You need to change the column reference

Code:
Sub MM1()
Dim lr As Long, r As Long
lr = Cells(Rows.Count, "A").End(xlUp).Row
For r = 2 To lr
    If Cells(r, 4).Value = "" Then
        Range(Cells(r - 1, 4), Cells(r - 1, 5)).Copy Cells(r, 4)
    End If
Next r
End Sub
 
Upvote 0
Try the following:

Code:
Sub Macro1()
    With Range("D2:E" & Range("D" & Rows.Count).End(xlUp).Row)
        .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
        .Value = .Value
    End With
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Similar threads

Forum statistics

Threads
1,214,827
Messages
6,121,803
Members
449,048
Latest member
greyangel23

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