Forum Discussion
hrh_dash
Aug 06, 2022Iron Contributor
VBA cut and insert
Somehow the cut and insert code for N and H is not working correctly..
Column N is actually showing the amount and Column G is showing the address. I would like to have the amount from column N to be inserted into column G.
The cut and insert code for column P and column G is working fine, not sure why the cut and insert for column N and column H is not working..
Sub BSCS_Outsource()
Dim ws As Worksheet
Dim lastRow As Long
Dim str1 As Variant
Dim str2 As Variant
For Each ws In Worksheets
ws.Range("A1").CurrentRegion.EntireColumn.AutoFit
ws.Range("A1").EntireRow.Delete
ws.Cells(ws.Rows.Count, "B").End(xlUp).EntireRow.Delete
ws.Range("D:D").NumberFormat = "0.00000000"
ws.Range("A1").CurrentRegion.RemoveDuplicates Columns:=4, Header:=xlYes
ws.Range("P:P").Cut
ws.Range("G:G").Insert
ws.Range("N:N").Cut '<--- not executing correctly
ws.Range("H:H").Insert '<--- not executing correctly
ws.Columns("I:AF").Delete
lastRow = ws.Cells(ws.Rows.Count, "B").End(xlUp).EntireRow.Row
str1 = ws.Range("B2:B" & lastRow).Value
str2 = ws.Range("C2:C" & lastRow).Value
ws.Range("I2:I" & lastRow).FormulaR1C1 = "=RC[-7]&"" ""& RC[-6]"
Next
End Sub
appreciate assistance in advance!
2 Replies
Do you mean that cutting N and inserting in H does nothing at all? Or does it do something you didn't intend?
Keep in mind that after cutting P and inserting into G, the original column N has moved to O and the original column H has moved to I. Could that be the cause of your problem?
- hrh_dashIron Contributorhahah, no wonder. I didn't thought of that. Now it is getting the data i want.