Hi Guys,
I have written the below code.... I am trying to delete all column between B1 and M1 where the value is not equal to that in R1. (to get the column headings/cell references i need to delete first 13 rows)
can someone please help me get this to work. currently the formula deletes all the columns
I have written the below code.... I am trying to delete all column between B1 and M1 where the value is not equal to that in R1. (to get the column headings/cell references i need to delete first 13 rows)
Code:
With ActiveSheet
ActiveSheet.Rows("1:13").Delete
End With
With ActiveSheet
ActiveSheet.Range("R1:AC1").Value = Worksheets("Value").range("G1")
ActiveSheet.Range("B1").Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = ActiveSheet.Range("r1") _
Then
ActiveCell.Offset(0, 1).Select
Else
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
Selection.End(xlUp).Select
End If
Loop
can someone please help me get this to work. currently the formula deletes all the columns
Last edited: