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
[TABLE="width: 624"]
<tbody>[TR]
[TD]Row1-00000000010054/000[/TD]
[TD]20 OZ FOUNTIAN[/TD]
[TD]$1.19[/TD]
[TD]4[/TD]
[TD]5[/TD]
[TD]$5.95[/TD]
[/TR]
[TR]
[TD]Row2-00000000010078/000[/TD]
[TD]32 OZ FOUNTIAN[/TD]
[TD]$1.39[/TD]
[TD]21[/TD]
[TD]21[/TD]
[TD]$29.19[/TD]
[/TR]
[TR]
[TD]Row3-[/TD]
[TD][/TD]
[TD]$1.19[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]$1.19[/TD]
[/TR]
[TR]
[TD]Row4-[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]22[/TD]
[TD]$30.38[/TD]
[/TR]
[TR]
[TD]Row5-00000000010511/000[/TD]
[TD]Refill Fntn[/TD]
[TD]$0.79[/TD]
[TD]11[/TD]
[TD]11[/TD]
[TD]$8.69[/TD]
[/TR]
[TR]
[TD]Row6-00000000010528/000[/TD]
[TD]44 OZ FOUNTIAN[/TD]
[TD]$1.29[/TD]
[TD]3[/TD]
[TD]3[/TD]
[TD]$3.87[/TD]
[/TR]
[TR]
[TD]Row7-[/TD]
[TD][/TD]
[TD]$1.49[/TD]
[TD]17[/TD]
[TD]21[/TD]
[TD]$31.29[/TD]
[/TR]
[TR]
[TD]Row8-[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD]24[/TD]
[TD]$35.16[/TD]
[/TR]
[TR]
[TD]00000000011037/000[/TD]
[TD]16oz Coffee[/TD]
[TD]$1.39[/TD]
[TD]4[/TD]
[TD]4[/TD]
[TD]$5.56[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Last edited:

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
So does A2:B2 go in rows 7 & 8 as well ??
The prices in C are different !
 
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

Similar threads

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

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