Delete Columns between Two Specific Columns (based on column heading name)

jwb1012

Board Regular
Joined
Oct 17, 2016
Messages
167
Hello, I have a unique situation where I need to delete the columns between two columns. The number of columns between these two will be different at various times... Column_B will always be the second column, but as columns are added in between, "Column_C" will push to the right


Here is my initial attempt... but it results in a run-time error 13 type mismatch. It highlights the bold/underlined line of code below.

Any thoughts? Thank you in advance for any guidance you may be able to provide.

Code:
Sub Res_Hrs_Cost()
    Dim Column_B As Integer
    Dim Column_C As Integer
    
    With Application
        .DisplayAlerts = False
        .ScreenUpdating = False
        .EnableEvents = False
    End With
    
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''        '(1.) DELETE COLUMNS BETWEEN START & END
        Set Dest_Sh = Sheets("SHEET 1")
        [I][U][B]Column_B = Dest_Sh.UsedRange.Find("Column B", , xlValues, xlWhole)[/B][/U][/I]
        Column_C = Dest_Sh.UsedRange.Find("Column C", , xlValues, xlWhole)
                If Column_C > 3 Then
                    Dest_Sh.Range(Cells(1, Column_B + 1), Cells(1, Column C - 1)).EntireColumn.Delete
                End If
                
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
              
ExitTheSub:
    Application.GoTo Dest_Sh.Cells(1)
    ActiveWindow.DisplayGridlines = False
    With Application
        .DisplayAlerts = True
        .ScreenUpdating = True
        .EnableEvents = True
    End With
    
End Sub
 

Forum statistics

Threads
1,226,859
Messages
6,193,397
Members
453,793
Latest member
MillionMonkeys

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