Remove the range of columns in Excel VBA

advertisements

I am trying to delete the range of columns but getting error "Application Defined or object defined error". In the below code wks is the worksheet and colStart and colEnd are variables with values.

Dim colDelete As String

colDelete = wks.Range(wks.Cells(1, colStart), wks.Cells(1, colEnd)).EntireColumn.Delete


Declare your variables. Always.

dim colStart as long
dim colEnd as long
dim wks as Worksheet

It should work this way.