Move Cell Value within the same Column Skipping Random Blanks Cells in between

EvelynCarly

New Member
Joined
Apr 18, 2020
Messages
8
Office Version
  1. 365
Platform
  1. Windows
Hi,

It might be very easy for your excel experts however I am stuck...

Any ideas on how to move cell value in the subtotal column to the corresponding row and skip the blank cells in between on Column H.

1. The current subtotal amount$ is on row below the breakdown on each items on the purchase order received.

2. I need the subtotal amount$ to be on the same rows that has the PO# and Vendor info.


Below is an image of the workbook.

Thank you in advance.. Feel free to let me know with any question. I can update the workbook



screen shot.PNG
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Sub MoveIt()
i = Range("H1048576").End(xlUp).Row
j = Range("B1048576").End(xlUp).Row
1:
Cells(i, 8).Cut Cells(j, 8)
If j < 3 Then Exit Sub
i = j - 1
j = Cells(j - 1, 2).End(xlUp).Row
GoTo 1
End Sub
 
Upvote 0
I'm assuming the destination cells start blank. Select the whole range with subtotals data & blanks, then select blank cells only (CTR-G, ALT-S, k, return), then enter = and down arrow and CTRL-ENTER to load to all cells. This fills those blank cells with the value from the cell below it. Now paste special values the entire range of subtotals data. Apply the auto-filter to column G for everything except "Status", and delete the visible cells in column H. Then show all on the column G filter. OK?
 
Upvote 0
Sub MoveIt()
i = Range("H1048576").End(xlUp).Row
j = Range("B1048576").End(xlUp).Row
1:
Cells(i, 8).Cut Cells(j, 8)
If j < 3 Then Exit Sub
i = j - 1
j = Cells(j - 1, 2).End(xlUp).Row
GoTo 1
End Sub


Awesome, thank you so much...……..
 
Upvote 0
I'm assuming the destination cells start blank. Select the whole range with subtotals data & blanks, then select blank cells only (CTR-G, ALT-S, k, return), then enter = and down arrow and CTRL-ENTER to load to all cells. This fills those blank cells with the value from the cell below it. Now paste special values the entire range of subtotals data. Apply the auto-filter to column G for everything except "Status", and delete the visible cells in column H. Then show all on the column G filter. OK?


OMG, this works wonderfully. Thank you so much for your help!!!!!!
 
Upvote 0
with 700,000 rows of data, you might prefer a faster approach. below is some VBA
be sure to back up the file before testing

VBA Code:
Sub anotherway()

    Dim i As Long
    Dim lLastRow As Long
    Dim cSubtotal As Currency
    Dim ar As Variant
    
    lLastRow = Cells(Rows.Count, "H").End(xlUp).Row
    With Range("H1:H" & lLastRow)
        ar = .Value2
        For i = lLastRow To 2 Step -1
            If Len(ar(i, 1)) > 0 Then
                cSubtotal = ar(i, 1)
                ar(i, 1) = vbNullString
            End If
            If Len(ar(i - 1, 1)) > 0 Then ar(i, 1) = cSubtotal
        Next i
        .Value2 = ar
    End With
End Sub
 
Upvote 0
with 700,000 rows of data, you might prefer a faster approach. below is some VBA
be sure to back up the file before testing

VBA Code:
Sub anotherway()

    Dim i As Long
    Dim lLastRow As Long
    Dim cSubtotal As Currency
    Dim ar As Variant
   
    lLastRow = Cells(Rows.Count, "H").End(xlUp).Row
    With Range("H1:H" & lLastRow)
        ar = .Value2
        For i = lLastRow To 2 Step -1
            If Len(ar(i, 1)) > 0 Then
                cSubtotal = ar(i, 1)
                ar(i, 1) = vbNullString
            End If
            If Len(ar(i - 1, 1)) > 0 Then ar(i, 1) = cSubtotal
        Next i
        .Value2 = ar
    End With
End Sub



Thanks a lot. I am very new to VBA coding. Allow me to test it out and will let you kown.

Cheers !
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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