Help! Simple cut, paste, delete row help needed!

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:
86hJg5W.jpg
86hJg5W


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.:confused:
Next i
End Sub

What I am hoping to get:
juwBwDY.jpg
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
How about
Code:
Sub elivegara()
   Dim Ar As Areas
   Dim Cl As Range
   
   Columns(1).Resize(, 2).Insert
   With Range("C2", Range("C" & Rows.Count).End(xlUp))
      .Replace "mfg / Mesa", "=XXX", xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlFormulas, xlErrors).Areas
      .Replace "=XXX", "mfg / Mesa", xlWhole, , False, , False, False
   End With
   For Each Cl In Ar
      Cl.Offset(-1).Resize(, 2).Cut Cl.Offset(, -2)
   Next Cl
   Range("C2:C104800").SpecialCells(xlBlanks).EntireRow.Delete
End Sub
 
Upvote 0
Thanks! This worked excellent except for one thing, there are two types of warehouse column values: "mfg / Mesa" and "Medical / Auer Medical" (I know the latter ones didn't show in my screenshot).
So when I ran this, it skipped moving the part number to "Medical / Auer Medical".
Is it possible to add two variables to move data to? I can try and modify the script, but I don't want to mess it up.
See below:
itQjdIt.jpg


Thank you so much!
 
Upvote 0
How about
Code:
Sub elivegara()
   Dim Ar As Areas
   Dim Cl As Range
   
   Columns(1).Resize(, 2).Insert
   With Range("C2", Range("C" & Rows.Count).End(xlUp))
      .Replace "mfg / Mesa", "=XXX", xlWhole, , False, , False, False
      .Replace "Medical / Auer Medical", "=XXX", xlWhole, , False, , False, False
      Set Ar = .SpecialCells(xlFormulas, xlErrors).Areas
      .Replace "=XXX", "mfg / Mesa", xlWhole, , False, , False, False
      .Replace "=XXX", "Medical / Auer Medical", xlWhole, , False, , False, False
   End With
   For Each Cl In Ar
      Cl.Offset(-1).Resize(, 2).Cut Cl.Offset(, -2)
   Next Cl
   Range("C2:C104800").SpecialCells(xlBlanks).EntireRow.Delete
End Sub
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,749
Members
448,989
Latest member
mariah3

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