restructure

MR3

Board Regular
Joined
Jun 10, 2008
Messages
175
Here is my input


this is my desired output


I am trying to write code to do this desired feature to move data to specific columns based off of the numerical value in the first column. Above is my input and my desired output. Any help would be greatly appreciated.

thanks in advance
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Try this:

Code:
Sub test()
Dim x As Long
Dim lastrow As Long
Dim nm As String
lastrow = ActiveSheet.UsedRange.Rows.Count
For x = 1 To lastrow
    nm = Range("B" & x).Value
    Range("B" & x).Clear
    Range("B" & x).Offset(0, Range("A" & x).Value - 1).Value = nm
Next x

End Sub
 
Upvote 0
Try

Code:
Option Base 1
Sub test()
Dim aNames, aOffsetNo, sName As String
Dim rCells As Range
Dim i As Long
 
'Capture inputs
aOffsetNo = Range("A2", Range("A" & Rows.Count).End(xlUp)).Value
aNames = Range("B2", Range("B" & Rows.Count).End(xlUp)).Value
 
'Clear Range
Range("B2", Range("B" & Rows.Count).End(xlUp)).ClearContents
For i = 1 To UBound(aOffsetNo)
  Range("A" & i + 1).Offset(0, aOffsetNo(i, 1)) = aNames(i, 1)
Next i
End Sub

Biz
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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