Forum Discussion

mary_anderson's avatar
mary_anderson
New Contributor
10 years ago
Solved

Excel Ranges - Using Column Numbers rather than letters

Hi all, As part of one of my routines, I'd like to "Clear Contents" of a range in Excel, using the COM object.  However, I'd like to use numbers to represent the columns rather than letters.  I...
  • amarr1143l's avatar
    10 years ago
    Try this:




    Sub clearRange


    set xl = Sys.OleObject("Excel.Application")


    xl.Visible = TRUE


    Set workbook = xl.ActiveWorkbook


    Set worksheet = workbook.ActiveSheet


    Set range1 = worksheet.Range(worksheet.Cells(11, 8), worksheet.Cells(15, 12))


    range1.clearContents


    End Sub