VBA or formula solution to shift up and transform data for multiple ranges on a sheet

gracemcth

New Member
Joined
Aug 12, 2020
Messages
2
Office Version
  1. 2019
Platform
  1. Windows
Any advice would be GREATLY APPRECIATED!!

I'm struggling to figure out a way to re-organize the data from a generated report into a more usable format. I have been able to get the data from the generated report to look like it does in the "before" columns, but I still need it to be shifted up [to the top row of each order] and transformed [the 3 amounts in the consult cost column transformed into the Consult Cost/Labor Cost/Material Cost columns] into how it looks in the "after" columns. This would be for a sheet with thousands of orders each with a varying number of rows.

THANK YOU AGAIN!!!

before and after v2.jpg
e
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Try:
VBA Code:
Sub Example()
    Dim r As Range
 
    For Each r In Range("A2:A" & Rows.CountLarge).SpecialCells(xlCellTypeConstants)
        Range(r.Offset(, 4).End(xlDown), r.Offset(, 4).End(xlDown).End(xlToRight).End(xlDown)).Cut r.Offset(, 4)
        r.Offset(, 8).End(xlDown).Resize(3).Copy
        r.Offset(, 8).PasteSpecial Transpose:=True
        r.Offset(, 8).End(xlDown).Resize(3).Clear
    Next
End Sub

Better yet:
VBA Code:
Sub Example()
    Dim r As Range
   
    Application.ScreenUpdating = False
    For Each r In Range("A2:A" & Rows.CountLarge).SpecialCells(xlCellTypeConstants)
        With r.Offset(, 4)
            Range(.End(xlDown), .End(xlDown).End(xlToRight).End(xlDown)).Cut .Cells(1)
        End With
        With r.Offset(, 8)
            .End(xlDown).Resize(3).Copy
            .PasteSpecial Transpose:=True
            .End(xlDown).Resize(3).Clear
        End With
    Next
    Application.ScreenUpdating = True
End Sub
 
Last edited by a moderator:
Upvote 0
Wow! Thank you so much for your ideas. This is a great starting point. Here's what I'm running into with the second code (and this could definitely be user error...lol). I'm wondering if I should insert a blank row in between each order and then do some type of "ctrl+shift+right" and "ctrl+shift+down" to select the data for that order, shift/transform it, then somehow tell the code to go to the row after the blank row deliminating each order and loop back to the "ctrl+shift+right".......?

Example 2 Input.jpg

Example 2 Output.jpg

Example 2 debug.jpg
 
Upvote 0
Grace, if possible, please drop a copy of your file here, noting the file name, or share it in some other way. I did not take the time to duplicate your file exactly and of course I don't know what might be in some of those apparently blank cells. There is an example in the folder linked to above named Grace 1.xlsm. Maybe you can work with that.
 
Upvote 0
Grace, we are unable to manipulate data in a picture. Please upload your sample data using XL2BB so that all here can have a look and try and help.
 
Upvote 0

Forum statistics

Threads
1,214,525
Messages
6,120,051
Members
448,940
Latest member
mdusw

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