elivergara
New Member
- Joined
- Mar 23, 2015
- Messages
- 13
Hi, I am trying to format an excel file where two rows combine into one row and empty rows are removed.
The goal is to insert two columns to the left of the sheet, then CUT the cells in C4:D4 (A4:B4 on the screenshot before two columns were inserted) the highlighted data, where the Part number and the "Non-Stock" are), and cut them, paste them on the inserted columns to the left of the row that starts with "mfg /Mesa", and then delete the empty rows below, and then repeat all the way to the last row of information. I really don't know how to make the process (For/Next) repeat until the last row.
At the bottom, I have included what I have been trying to do in VBA (and failing) and below that what I want to accomplish.
Any help will be greatly appreciated! (A Plus would be to remove the "Part: " from before the part# and convert the result to number format... but that might be asking for too much of your time
This is the original spreadsheet:
What I have been unsuccessfully playing with:
Sub Stock_Status_calculable()
ActiveWorkbook.ActiveSheet.Select
Dim lastrow As Long
lastrow = Cells.SpecialCells(xlCellTypeLastCell).Row
Range("A1").Select
Columns("A:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C4:D4").Select
Selection.Cut
Range("A5").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select
Set DelRange = ActiveCell
DelRange.EntireRow.Delete
For i = ActiveCell.Row To lastrow
I don't really know what I need here to make this work and repeat.
Next i
End Sub
What I am hoping to get:
The goal is to insert two columns to the left of the sheet, then CUT the cells in C4:D4 (A4:B4 on the screenshot before two columns were inserted) the highlighted data, where the Part number and the "Non-Stock" are), and cut them, paste them on the inserted columns to the left of the row that starts with "mfg /Mesa", and then delete the empty rows below, and then repeat all the way to the last row of information. I really don't know how to make the process (For/Next) repeat until the last row.
At the bottom, I have included what I have been trying to do in VBA (and failing) and below that what I want to accomplish.
Any help will be greatly appreciated! (A Plus would be to remove the "Part: " from before the part# and convert the result to number format... but that might be asking for too much of your time
This is the original spreadsheet:
What I have been unsuccessfully playing with:
Sub Stock_Status_calculable()
ActiveWorkbook.ActiveSheet.Select
Dim lastrow As Long
lastrow = Cells.SpecialCells(xlCellTypeLastCell).Row
Range("A1").Select
Columns("A:B").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("C4:D4").Select
Selection.Cut
Range("A5").Select
ActiveSheet.Paste
ActiveCell.Offset(1, 0).Select
Set DelRange = ActiveCell
DelRange.EntireRow.Delete
For i = ActiveCell.Row To lastrow
I don't really know what I need here to make this work and repeat.
Next i
End Sub
What I am hoping to get: