Copying of Data from one column to another (misaligned data)

ExcelPupper

Board Regular
Joined
Mar 2, 2020
Messages
112
Office Version
  1. 2019
Platform
  1. Windows
Hi, I have this set of data (picture 1) that is generated from the system and I need to format it the same as picture 2 (kindly refer to pictures below)
As of now, I am stuck on identifying the first and last row for items ordered per Supplier in order to insert the respective Supplier on the column beside the items.
Any help is much appreciated. Thanks!

PS: Items ordered per Supplier is variable
VBA Code:
Sub CopySupplierName()
Dim lr As Long


    lr =
    Range("C4:C" & lr).Value = Range("A" & 4 - 2).Value
 

End Sub


Picture 1
1622990133498.png


Picture 2
1622988565238.png
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about
VBA Code:
Sub ExcelPupper()
   Dim Rng As Range
   
   With Range("B2", Range("B" & Rows.Count).End(xlUp))
      For Each Rng In .SpecialCells(xlConstants).Areas
         Rng.Offset(, 1).Value = Rng.Offset(-2, -1).Resize(1).Value
      Next Rng
      .SpecialCells(xlBlanks).EntireRow.Delete
   End With
End Sub
 
Upvote 0
Solution
How about
VBA Code:
Sub ExcelPupper()
   Dim Rng As Range
  
   With Range("B2", Range("B" & Rows.Count).End(xlUp))
      For Each Rng In .SpecialCells(xlConstants).Areas
         Rng.Offset(, 1).Value = Rng.Offset(-2, -1).Resize(1).Value
      Next Rng
      .SpecialCells(xlBlanks).EntireRow.Delete
   End With
End Sub
works like a charm. Thanks!
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,839
Members
449,193
Latest member
MikeVol

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