Excel Macro to rearrange data- combine cells and move sheets

Closed
Report
Posts
2
Registration date
Wednesday September 16, 2015
Status
Member
Last seen
September 16, 2015
-
Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
-
Hello,

I am just starting to use macros and am lost on figuring this out. Any help would be appreciated, thanks.


Inventory comes in a 9x9 box with position 1,1 (rows, columns) in the bottom left
I have an inventory spreadsheet I get in that has 4 columns of pertinent info. Column D,G and M all have info I need to combine and place in a cell location based upon column 14. Preferably the data would be formatted to have each of the 3 original cell data on a new line within the new cell.


Sample Input



Sample Output

1 reply

Posts
2829
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
November 22, 2021
490
Hi Masayaanglibre,

The code below isn't based on the position found in column N. It fills out the first 9 cells of the first row and then moves on to the second row.

See if the code does what you want it to do:

Sub RunMe()
Dim x As Integer

Sheets("Sheet2").Select
With Range("A1:I9")
    .RowHeight = 46.5
    .ColumnWidth = 9.86
    .WrapText = True
End With

x = 1

For Each cell In Range("A1:I9")
    x = x + 1
    cell.Value = Sheets("Sheet1").Range("D" & x).Value & " " & _
    Format(Sheets("Sheet1").Range("G" & x).Value, "d-mmm-yy") & " " & _
    Sheets("Sheet1").Range("M" & x).Value
Next cell

End Sub


Best regards,
Trowa