Array_delete column till end

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I am little confused
quote
<table width="303" border="0" cellpadding="0" cellspacing="0"><col width="303"><tr height="20"> <td style="height: 15pt; width: 227pt;" height="20" width="303">both Test 1 & Test 2 columns should get deleted from sheet("Main data")</td> </tr></table>unquote
test 2 is in column C in main data sheet

nexti if it is process2 again you say
" <table width="303" border="0" cellpadding="0" cellspacing="0"><col style="width: 227pt;" width="303"> <tbody><tr style="height: 15pt;" height="20"> <td style="height: 15pt; width: 227pt;" height="20" width="303">Test 2,4,5,6 columns</td> </tr> <tr style="height: 15pt;" height="20"> <td style="height: 15pt;" height="20">should be deleted on Main data sheet"</td> </tr> </tbody></table>
column C has been deleted.
This confusion arises as I do not know the full configuration.

any how I have modified your macro. see whether this helps you

Code:
Sub deletecol()
Dim rng As Range
Dim c As Range
Dim v As Variant
Dim cfind As Range
Dim x() As Variant, j As Integer, k As Integer
Dim cfind1 As Range
Worksheets("main data").Activate
Set rng = Range("A1:A100")
For Each c In rng
v = c.Offset(0, 1)
With Worksheets("criteria")
Set cfind = .Cells.Find(what:=v, lookat:=xlWhole)
If Not cfind Is Nothing Then
j = WorksheetFunction.CountA(cfind.Offset(0, 1), cfind.End(xlToRight))
ReDim x(1 To j)
For k = 1 To j
x(k) = cfind.Offset(0, k)
Next k
End If
End With
For k = 1 To j
Set cfind1 = Rows(c.Row).Cells.Find(what:=x(k), lookat:=xlWhole)
cfind1.EntireColumn.Delete
Next k
Next c

'If Range("C1").Value = c Then
''Range("C2").Value = c.Offset(0, 1).Value
'v = Array((c.Offset(0, 1).Value))
'LastCol = Cells(1, Columns.Count).End(xlToLeft).Column
'For delcol = LastCol To 1 Step -1
'bFound = False
'For x = LBound(v) To UBound(v)
'  If InStr(1, Cells(1, delcol), v(x), vbTextCompare) And _
'   Len(Cells(1, delcol)) = Len(v(x)) Then
'    bFound = True
'    Exit For
'  End If
'Next x
'If bFound Then _
'  Cells(1, delcol).EntireColumn.Delete
'Next delcol
'End If
'Next c
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,503
Messages
6,179,135
Members
452,890
Latest member
Nikhil Ramesh

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